Strongly-typed AST types for Rust, auto-generated from
tree-sitter-rust's node-types.json.
This crate is generated by treesitter-types and is
automatically kept up to date when a new version of the grammar crate is released.
These types have been tested by parsing the Rust compiler source code.
See the Tree-sitter project for more information about the underlying parser framework.
Example
use *;
// A minimal Rust hello-world program.
let src = b"\
fn main() {
println!(\"Hello, World!\");
}
";
// Parse the source with tree-sitter and convert into typed AST.
let mut parser = new;
parser.set_language.unwrap;
let tree = parser.parse.unwrap;
let source_file = from_node.unwrap;
// The source file has one top-level child: a function definition.
assert_eq!;
// Unwrap the function item through the declaration statement wrapper.
let DeclarationStatement = &source_file.children else ;
let FunctionItem = decl.as_ref else ;
// Check function metadata.
let Identifier = &func.name else ;
assert_eq!;
assert!; // no parameters
assert!; // no return type
// The body contains one statement: the `println!` macro invocation.
assert_eq!;