pub struct Node { /* private fields */ }Expand description
A single syntax node within a Tree.
Nodes hold a strong reference to their parent tree so they remain valid regardless of how the tree is moved or stored at the FFI boundary.
Implementations§
Source§impl Node
impl Node
Sourcepub fn start_byte(&self) -> usize
pub fn start_byte(&self) -> usize
Return the inclusive start byte offset of this node.
Sourcepub fn byte_range(&self) -> ByteRange
pub fn byte_range(&self) -> ByteRange
Return the node’s byte range as a ByteRange.
Callers should slice their own source bytes — this is a zero-copy text accessor.
Sourcepub fn start_position(&self) -> Point
pub fn start_position(&self) -> Point
Return the start Point (row, column).
Sourcepub fn end_position(&self) -> Point
pub fn end_position(&self) -> Point
Return the end Point (row, column).
Sourcepub fn is_missing(&self) -> bool
pub fn is_missing(&self) -> bool
True when this is a missing-token node.
Sourcepub fn child_count(&self) -> usize
pub fn child_count(&self) -> usize
Total number of children (including unnamed).
Sourcepub fn named_child(&self, index: u32) -> Option<Node>
pub fn named_child(&self, index: u32) -> Option<Node>
Return the i-th named child of this node, if any.
Sourcepub fn named_child_count(&self) -> usize
pub fn named_child_count(&self) -> usize
Number of named children of this node.
Sourcepub fn child_by_field_name(&self, name: &str) -> Option<Node>
pub fn child_by_field_name(&self, name: &str) -> Option<Node>
Look up a child by its grammar-defined field name.
Sourcepub fn walk(&self) -> TreeCursor
pub fn walk(&self) -> TreeCursor
Return a TreeCursor positioned at this node.
Trait Implementations§
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