mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-25 23:21:15 -03:00
ast: introduce Kind and cast
This begins the process of replacing the underlying Node "type" notion with
Kind. A Kind is an Enum of all of the possible node types, except with
Token and Keyword collapsed into one.
The idea is, rather than this:
if node.type() == Type::Argument {
let arg = node.as_argument().unwrap();
...
}
we can instead do this:
if let Kind::Argument(arg) = node.kind() {
// we already have arg
}
There is also a cast() function:
let arg: Option<Argument> = node.cast()
which may be convenient in some places.
The big thing we lose is the ability to talk about a Node's type without
actually having a Node. But this turns out to not be an issue in practice.
Future commits will begin adopting Kind.
This commit is contained in:
1049
src/ast.rs
1049
src/ast.rs
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user