#[repr(C)]pub struct Node {
pub kind: u16,
pub flags: u16,
pub pos: u32,
pub end: u32,
pub data_index: u32,
}Expand description
A thin 16-byte node header for cache-efficient AST storage.
Layout (16 bytes total):
kind: 2 bytes (SyntaxKindvalue, supports 0-65535)flags: 2 bytes (packedNodeFlags)pos: 4 bytes (start position in source)end: 4 bytes (end position in source)data_index: 4 bytes (index into type-specific pool,u32::MAX= no data)
Fields§
§kind: u16SyntaxKind value (u16 to support extended kinds up to 400+)
flags: u16Packed node flags (subset of NodeFlags that fits in u16)
pos: u32Start position in source (character index)
end: u32End position in source (character index)
data_index: u32Index into the type-specific storage pool (u32::MAX = no data)
Implementations§
Source§impl Node
impl Node
pub const NO_DATA: u32 = u32::MAX
Sourcepub const fn new(kind: u16, pos: u32, end: u32) -> Self
pub const fn new(kind: u16, pos: u32, end: u32) -> Self
Create a new thin node with no associated data
Sourcepub const fn with_data(kind: u16, pos: u32, end: u32, data_index: u32) -> Self
pub const fn with_data(kind: u16, pos: u32, end: u32, data_index: u32) -> Self
Create a new thin node with data index
Source§impl Node
impl Node
Sourcepub const fn is_identifier(&self) -> bool
pub const fn is_identifier(&self) -> bool
Check if this is an identifier node
Sourcepub const fn is_string_literal(&self) -> bool
pub const fn is_string_literal(&self) -> bool
Check if this is a string literal
Sourcepub const fn is_numeric_literal(&self) -> bool
pub const fn is_numeric_literal(&self) -> bool
Check if this is a numeric literal
Sourcepub const fn is_function_declaration(&self) -> bool
pub const fn is_function_declaration(&self) -> bool
Check if this is a function declaration
Sourcepub const fn is_class_declaration(&self) -> bool
pub const fn is_class_declaration(&self) -> bool
Check if this is a class declaration
Sourcepub const fn is_function_like(&self) -> bool
pub const fn is_function_like(&self) -> bool
Check if this is any kind of function-like node
Sourcepub fn is_statement(&self) -> bool
pub fn is_statement(&self) -> bool
Check if this is a statement
Sourcepub fn is_declaration(&self) -> bool
pub fn is_declaration(&self) -> bool
Check if this is a declaration
Sourcepub fn is_type_node(&self) -> bool
pub fn is_type_node(&self) -> bool
Check if this is a type node
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Node
impl<'de> Deserialize<'de> for Node
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Copy for Node
Auto Trait Implementations§
impl Freeze for Node
impl RefUnwindSafe for Node
impl Send for Node
impl Sync for Node
impl Unpin for Node
impl UnsafeUnpin for Node
impl UnwindSafe for Node
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