pub struct GreenLeaf<L: Language> {
pub kind: L::TokenType,
pub length: u32,
pub metadata: Option<NonZeroU32>,
}Expand description
A green leaf kind that stores only kind and length.
Leaves are the terminal elements of the green tree, representing individual tokens in the source code.
Fields§
§kind: L::TokenTypeThe token kind/category.
length: u32The byte length of the token text.
metadata: Option<NonZeroU32>Optional index into the metadata store for provenance information.
This is used to track where a token came from in complex transformations or multi-file sources.
Implementations§
Source§impl<L: Language> GreenLeaf<L>
impl<L: Language> GreenLeaf<L>
Sourcepub fn new(kind: L::TokenType, len: u32) -> Self
pub fn new(kind: L::TokenType, len: u32) -> Self
Creates a new green leaf kind.
§Arguments
kind- The token type.len- The length of the token in bytes.
Sourcepub fn with_metadata(
kind: L::TokenType,
len: u32,
metadata: Option<NonZeroU32>,
) -> Self
pub fn with_metadata( kind: L::TokenType, len: u32, metadata: Option<NonZeroU32>, ) -> Self
Creates a new green leaf kind with provenance metadata.
§Arguments
kind- The token type.len- The length of the token in bytes.metadata- The metadata index.
Trait Implementations§
impl<L: Language> Copy for GreenLeaf<L>
impl<L: Language> Eq for GreenLeaf<L>
Auto Trait Implementations§
impl<L> Freeze for GreenLeaf<L>
impl<L> RefUnwindSafe for GreenLeaf<L>
impl<L> Send for GreenLeaf<L>
impl<L> Sync for GreenLeaf<L>
impl<L> Unpin for GreenLeaf<L>
impl<L> UnsafeUnpin for GreenLeaf<L>
impl<L> UnwindSafe for GreenLeaf<L>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more