pub struct Node<'a> {
pub name: &'static str,
pub start: usize,
pub end: usize,
pub contents: NodeContents<'a>,
}
Fields§
§name: &'static str
The name of the node.
start: usize
The (inclusive) start index of the range this node matches. It’s the byte (NOT char) offset of the parse input.
end: usize
The (exclusive) end index of the range this node matches. It’s the byte (NOT char) offset of the parse input.
contents: NodeContents<'a>
The contents of the node; this can be either children nodes or a matched
&[u8]
slice.
Implementations§
Source§impl<'a> Node<'a>
impl<'a> Node<'a>
Sourcepub fn displayName(&self) -> &'static str
pub fn displayName(&self) -> &'static str
The node name if set, or “
Sourcepub fn withoutName(
start: usize,
end: usize,
contents: NodeContents<'a>,
) -> Node<'a>
pub fn withoutName( start: usize, end: usize, contents: NodeContents<'a>, ) -> Node<'a>
Creates a Node
with an empty name.
Sourcepub fn withChildren(name: &'static str, children: Vec<Node<'a>>) -> Node<'a>
pub fn withChildren(name: &'static str, children: Vec<Node<'a>>) -> Node<'a>
Creates a Node
with the provided name
and makes it a parent of the
provided children
.
Sourcepub fn preOrder<'b>(&'b self) -> PreOrderNodes<'b, 'a> ⓘ
pub fn preOrder<'b>(&'b self) -> PreOrderNodes<'b, 'a> ⓘ
Traverses the tree rooted at the node with pre-order traversal. Includes
the self
node as the first node.
Sourcepub fn matchedData(&self) -> Vec<u8> ⓘ
pub fn matchedData(&self) -> Vec<u8> ⓘ
Concatenates and returns all &[u8]
data in the leaf nodes beneath
the current node.
Trait Implementations§
impl<'a> StructuralPartialEq for Node<'a>
Auto Trait Implementations§
impl<'a> Freeze for Node<'a>
impl<'a> RefUnwindSafe for Node<'a>
impl<'a> Send for Node<'a>
impl<'a> Sync for Node<'a>
impl<'a> Unpin for Node<'a>
impl<'a> UnwindSafe for Node<'a>
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