pub struct RustAST { /* private fields */ }Expand description
Rust source code with parsed AST.
This is the main entry point for AST manipulation.
It wraps a syn::File and provides high-level operations.
Implementations§
Source§impl RustAST
impl RustAST
Sourcepub fn parse(source: &str) -> SourceResult<Self>
pub fn parse(source: &str) -> SourceResult<Self>
Parse Rust source code into an AST.
Sourcepub fn from_file(path: &Path) -> SourceResult<Self>
pub fn from_file(path: &Path) -> SourceResult<Self>
Load and parse a Rust file.
Sourcepub fn to_string_pretty(&self) -> String
pub fn to_string_pretty(&self) -> String
Convert the AST to a pretty-printed source code.
Sourcepub fn to_token_stream(&self) -> TokenStream
pub fn to_token_stream(&self) -> TokenStream
Get the token stream.
Sourcepub fn collect_imports(&self) -> Vec<&ItemUse>
pub fn collect_imports(&self) -> Vec<&ItemUse>
Collect all use statements.
Sourcepub fn collect_used_identifiers(&self) -> HashSet<String>
pub fn collect_used_identifiers(&self) -> HashSet<String>
Collect all identifiers used in the code (excluding imports).
Sourcepub fn find_unused_imports(&self) -> Vec<UnusedImport>
pub fn find_unused_imports(&self) -> Vec<UnusedImport>
Find unused imports.
Sourcepub fn remove_unused_imports(&mut self) -> Vec<UnusedImport>
pub fn remove_unused_imports(&mut self) -> Vec<UnusedImport>
Remove all unused imports. Returns the removed imports.
Sourcepub fn filter_items<F>(&self, predicate: F) -> Vec<&Item>
pub fn filter_items<F>(&self, predicate: F) -> Vec<&Item>
Filter items by type.
Sourcepub fn structs(&self) -> Vec<&ItemStruct>
pub fn structs(&self) -> Vec<&ItemStruct>
Get all structs.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RustAST
impl RefUnwindSafe for RustAST
impl !Send for RustAST
impl !Sync for RustAST
impl Unpin for RustAST
impl UnsafeUnpin for RustAST
impl UnwindSafe for RustAST
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