pub trait SyntaxNode {
// Provided methods
fn span(&self) -> Option<Span> { ... }
fn ident(&self) -> Option<Ident> { ... }
fn attributes(&self) -> &[AttributeNode] ⓘ { ... }
fn attributes_mut(&mut self) -> &mut [AttributeNode] ⓘ { ... }
fn contains_attribute(&self, attribute: &Attribute) -> bool { ... }
fn retain_attributes_mut<F>(&mut self, _predicate: F)
where F: FnMut(&mut Attribute) -> bool { ... }
}Expand description
Trait implemented for all syntax node types.
This trait is useful for generic implementations over different syntax node types.
Node types that do not have a span, an ident, or attributes return None.
Provided Methods§
Sourcefn attributes(&self) -> &[AttributeNode] ⓘ
fn attributes(&self) -> &[AttributeNode] ⓘ
List all attributes of a syntax node.
Sourcefn attributes_mut(&mut self) -> &mut [AttributeNode] ⓘ
fn attributes_mut(&mut self) -> &mut [AttributeNode] ⓘ
List all attributes of a syntax node.
Sourcefn contains_attribute(&self, attribute: &Attribute) -> bool
fn contains_attribute(&self, attribute: &Attribute) -> bool
Whether the node contains an attribute.
Sourcefn retain_attributes_mut<F>(&mut self, _predicate: F)
fn retain_attributes_mut<F>(&mut self, _predicate: F)
Remove attributes with predicate.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementors§
impl SyntaxNode for Expression
impl SyntaxNode for GlobalDeclaration
impl SyntaxNode for GlobalDirective
impl SyntaxNode for LiteralExpression
impl SyntaxNode for Statement
impl SyntaxNode for AssignmentStatement
impl SyntaxNode for BinaryExpression
impl SyntaxNode for BreakIfStatement
impl SyntaxNode for BreakStatement
impl SyntaxNode for CompoundStatement
impl SyntaxNode for ConstAssert
impl SyntaxNode for ContinueStatement
impl SyntaxNode for ContinuingStatement
impl SyntaxNode for Declaration
impl SyntaxNode for DecrementStatement
impl SyntaxNode for DiagnosticDirective
impl SyntaxNode for DiscardStatement
impl SyntaxNode for ElseClause
impl SyntaxNode for ElseIfClause
impl SyntaxNode for EnableDirective
impl SyntaxNode for ForStatement
impl SyntaxNode for FormalParameter
impl SyntaxNode for Function
impl SyntaxNode for FunctionCall
impl SyntaxNode for FunctionCallStatement
impl SyntaxNode for IfClause
impl SyntaxNode for IfStatement
impl SyntaxNode for ImportStatement
Available on crate feature
imports only.