Struct Node

Source
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>

Source

pub fn displayName(&self) -> &'static str

The node name if set, or “” if unset.

Source

pub fn withoutName( start: usize, end: usize, contents: NodeContents<'a>, ) -> Node<'a>

Creates a Node with an empty name.

Source

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.

Source

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.

Source

pub fn matchedData(&self) -> Vec<u8>

Concatenates and returns all &[u8] data in the leaf nodes beneath the current node.

Trait Implementations§

Source§

impl<'a> Debug for Node<'a>

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> PartialEq for Node<'a>

Source§

fn eq(&self, other: &Node<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.