pub enum SyntaxStablePtr {
    Root,
    Child {
        parent: SyntaxStablePtrId,
        kind: SyntaxKind,
        key_fields: Vec<GreenId>,
        index: usize,
    },
}
Expand description

Stable pointer to a node in the syntax tree. Has enough information to uniquely define a node in the AST, given the tree. Has undefined behavior when used with the wrong tree. This is not a real pointer in the low-level sense, just a representation of the path from the root to the node. Stable means that when the AST is changed, pointers of unchanged items tend to stay the same. For example, if a function is changed, the pointer of an unrelated function in the AST should remain the same, as much as possible.

Variants§

§

Root

The root node of the tree.

§

Child

Fields

§parent: SyntaxStablePtrId

The parent of the node.

§kind: SyntaxKind

The SyntaxKind of the node.

§key_fields: Vec<GreenId>

A list of field values for this node, to index by. Which fields are used is determined by each SyntaxKind. For example, a function item might use the name of the function.

§index: usize

Chronological index among all nodes with the same (parent, kind, key_fields).

A child node.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Compare self to key and return true if they are equal.

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.