Skip to main content

ElementType

Trait ElementType 

Source
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§

Source

type Role: ElementRole

The associated role type for this element kind.

Required Methods§

Source

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§

Source

fn is_role(&self, role: Self::Role) -> bool

Returns true if this element matches the specified language-specific role.

Source

fn is_universal(&self, role: UniversalElementRole) -> bool

Returns true if this element matches the specified universal role.

Source

fn is_root(&self) -> bool

Returns true if this element represents the root of the parsed tree.

Source

fn is_error(&self) -> bool

Returns true if this element represents an error condition.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§