AnyNode

Trait AnyNode 

Source
pub trait AnyNode<'a>:
    BasicNode<'a>
    + AnyNodeData
    + Display
    + Send
    + Sync {
    // Required methods
    fn id(&self) -> NodeId;
    fn span(&self) -> Span;
    fn order(&self) -> usize;

    // Provided methods
    fn human_span(&self) -> Span { ... }
    fn get_parent(&self) -> Option<&'a dyn AnyNode<'a>> { ... }
    fn link(&'a self, parent: Option<&'a dyn AnyNode<'a>>, order: &mut usize) { ... }
    fn link_attach(&'a self, parent: &'a dyn AnyNode<'a>, order: usize) { ... }
    fn as_ptr(&self) -> *const u8 { ... }
}
Expand description

An AST node.

Required Methods§

Source

fn id(&self) -> NodeId

Get this node’s unique ID.

Source

fn span(&self) -> Span

Get this node’s span in the input.

Source

fn order(&self) -> usize

Get this node’s lexical order.

Provided Methods§

Source

fn human_span(&self) -> Span

Get a span that is terse and suitable to pinpoint the node for a human.

Source

fn get_parent(&self) -> Option<&'a dyn AnyNode<'a>>

Get this node’s parent.

Link up this node.

Link up this node as an expansion of another node.

All subnodes inherit the order from their parent. Useful if a node is generated as part of a later expansion/analysis pass, but needs to hook into the AST somewhere.

Source

fn as_ptr(&self) -> *const u8

Convert this node reference to a pointer for identity comparisons.

Trait Implementations§

Source§

impl<'a> Hash for &'a dyn AnyNode<'a>

Source§

fn hash<H: Hasher>(&self, h: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a> PartialEq for &'a dyn AnyNode<'a>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> Eq for &'a dyn AnyNode<'a>

Implementors§

Source§

impl<'a> AnyNode<'a> for TypeOrExpr<'a>

Source§

impl<'a, T> AnyNode<'a> for Node<'a, T>
where Self: BasicNode<'a> + Display + AnyNodeData, T: Debug + ForEachChild<'a> + Send + Sync,

Automatically implement AnyNode for Node<T> if enough information is present.