pub struct RustParser { /* private fields */ }Expand description
Tree-sitter parser wrapper for Rust source code.
Implementations§
Source§impl RustParser
impl RustParser
Sourcepub fn new() -> Result<Self, TreeSitterError>
pub fn new() -> Result<Self, TreeSitterError>
Create a new Rust parser with the default edition (2021).
Sourcepub fn with_edition(edition: RustEdition) -> Result<Self, TreeSitterError>
pub fn with_edition(edition: RustEdition) -> Result<Self, TreeSitterError>
Create a new Rust parser targeting a specific edition.
Sourcepub fn edition(&self) -> RustEdition
pub fn edition(&self) -> RustEdition
Get the configured edition.
Sourcepub fn parse(&mut self, source: &str) -> Result<Tree, TreeSitterError>
pub fn parse(&mut self, source: &str) -> Result<Tree, TreeSitterError>
Parse source code into a tree-sitter Tree.
Sourcepub fn parse_with_source<'a>(
&mut self,
source: &'a str,
) -> Result<ParsedSource<'a>, TreeSitterError>
pub fn parse_with_source<'a>( &mut self, source: &'a str, ) -> Result<ParsedSource<'a>, TreeSitterError>
Parse source code and return the tree along with the source.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RustParser
impl RefUnwindSafe for RustParser
impl Send for RustParser
impl Sync for RustParser
impl Unpin for RustParser
impl UnsafeUnpin for RustParser
impl UnwindSafe for RustParser
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more