pub trait ElementType:
Copy
+ Eq
+ Hash
+ Send
+ Sync
+ Debug {
type Role: ElementRole;
// Required method
fn role(&self) -> Self::Role;
// Provided methods
fn is_role(&self, role: Self::Role) -> bool { ... }
fn is_universal(&self, role: UniversalElementRole) -> bool { ... }
fn is_root(&self) -> bool { ... }
fn is_error(&self) -> bool { ... }
}Expand description
A trait for types that represent an element’s kind in a syntax tree.
Required Associated Types§
Sourcetype Role: ElementRole
type Role: ElementRole
The associated role type for this element kind.
Required Methods§
Sourcefn role(&self) -> Self::Role
fn role(&self) -> Self::Role
Returns the general syntactic role of this element.
The role enables structural analysis without knowing the specific grammar.
For example, a tool can find all UniversalElementRole::Definition nodes
to build a symbol outline for any supported language.
Provided Methods§
Sourcefn is_role(&self, role: Self::Role) -> bool
fn is_role(&self, role: Self::Role) -> bool
Returns true if this element matches the specified language-specific role.
Sourcefn is_universal(&self, role: UniversalElementRole) -> bool
fn is_universal(&self, role: UniversalElementRole) -> bool
Returns true if this element matches the specified universal role.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".