pub struct Cursor<'a, L: Language> { /* private fields */ }Expand description
A cursor for traversing a GreenTree.
It maintains a path from the root to the current node, allowing for
parent() navigation and offset tracking.
Implementations§
Source§impl<'a, L: Language> Cursor<'a, L>
impl<'a, L: Language> Cursor<'a, L>
Sourcepub fn new(root: &'a GreenNode<'a, L>) -> Self
pub fn new(root: &'a GreenNode<'a, L>) -> Self
Creates a new cursor starting at the given root node.
Sourcepub fn as_node(&self) -> Option<&'a GreenNode<'a, L>>
pub fn as_node(&self) -> Option<&'a GreenNode<'a, L>>
Returns the current element as a node, if it is one.
Sourcepub fn end_offset(&self) -> usize
pub fn end_offset(&self) -> usize
Returns the absolute end offset of the current element.
Sourcepub fn step_into(&mut self) -> bool
pub fn step_into(&mut self) -> bool
Tries to move to the first child of the current node. Returns true if successful (current was a node with children).
Sourcepub fn step_over(&mut self) -> bool
pub fn step_over(&mut self) -> bool
Tries to move to the next sibling. Returns true if successful.
Sourcepub fn step_out(&mut self) -> bool
pub fn step_out(&mut self) -> bool
Tries to move to the parent node. Returns true if successful (not at root).
Trait Implementations§
Auto Trait Implementations§
impl<'a, L> Freeze for Cursor<'a, L>
impl<'a, L> RefUnwindSafe for Cursor<'a, L>
impl<'a, L> Send for Cursor<'a, L>
impl<'a, L> Sync for Cursor<'a, L>
impl<'a, L> Unpin for Cursor<'a, L>
impl<'a, L> UnwindSafe for Cursor<'a, L>where
<L as Language>::TokenType: UnwindSafe + RefUnwindSafe,
<L as Language>::ElementType: RefUnwindSafe,
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