Cursor

Trait Cursor 

Source
pub trait Cursor {
    type Node;

    // Required methods
    fn goto_first_child(&mut self) -> bool;
    fn goto_parent(&mut self) -> bool;
    fn goto_next_sibling(&mut self) -> bool;
    fn node(&self) -> Self::Node;
}
Expand description

Trait which represents a stateful cursor in a n-ary tree. The cursor can be moved between nodes in the tree by the given methods, and the node which the cursor is currently pointing at can be read as well.

Required Associated Types§

Source

type Node

The type of the nodes which the cursor points at; the cursor is always pointing at exactly one of this type.

Required Methods§

Source

fn goto_first_child(&mut self) -> bool

Move this cursor to the first child of its current node.

This returns true if the cursor successfully moved, and returns false if there were no children.

Source

fn goto_parent(&mut self) -> bool

Move this cursor to the parent of its current node.

This returns true if the cursor successfully moved, and returns false if there was no parent node (the cursor was already on the root node).

Source

fn goto_next_sibling(&mut self) -> bool

Move this cursor to the next sibling of its current node.

This returns true if the cursor successfully moved, and returns false if there was no next sibling node.

Source

fn node(&self) -> Self::Node

Get the node which the cursor is currently pointing at.

Implementations on Foreign Types§

Source§

impl<'a> Cursor for TreeCursor<'a>

Available on crate feature tree-sitter only.

Quintessential implementation of Cursor for tree-sitter’s TreeCursor

Source§

type Node = Node<'a>

Source§

fn goto_first_child(&mut self) -> bool

Source§

fn goto_parent(&mut self) -> bool

Source§

fn goto_next_sibling(&mut self) -> bool

Source§

fn node(&self) -> Self::Node

Source§

impl<'a, T> Cursor for &'a mut T
where T: Cursor,

Source§

type Node = <T as Cursor>::Node

Source§

fn goto_first_child(&mut self) -> bool

Source§

fn goto_parent(&mut self) -> bool

Source§

fn goto_next_sibling(&mut self) -> bool

Source§

fn node(&self) -> Self::Node

Implementors§