Struct nutrimatic::ChildReader[][src]

pub struct ChildReader<'buf>(_);

A lazy reader of the children of a node.

This struct is created by the children method on Node. It conceptually represents a sequence of Nodes indexed by contiguous numbers, kind of like [Node]; however, it does not physically contain any instances, instead constructing them on demand.

Examples

use nutrimatic::Node;

// Materialize all the children of a node into a `Vec`.
fn collect_children<'a>(node: &Node<'a>) -> Vec<Node<'a>> {
    node.children().iter().collect()
}

Implementations

impl<'buf> ChildReader<'buf>[src]

pub fn index(&self, index: usize) -> Node<'buf>[src]

Returns the child at the given index, starting from 0. Children are in increasing order by character. If the index is not within bounds, this method will panic or return garbage.

pub fn len(&self) -> usize[src]

Returns the number of children of the node.

pub fn is_empty(&self) -> bool[src]

Returns true if the node has no children.

pub fn find(&self, ch: u8) -> Option<Node<'buf>>[src]

Finds a child with the given character using binary search.

pub fn scan(&self, ch: u8) -> Option<Node<'buf>>[src]

Finds a child with the given character by scanning through the children in order. This is useful when the character is known to be early in the list (in particular, the space character is always first if present).

pub fn iter<'reader>(&'reader self) -> ChildIter<'buf, 'reader>

Notable traits for ChildIter<'buf, 'reader>

impl<'buf, 'reader> Iterator for ChildIter<'buf, 'reader> type Item = Node<'buf>;
[src]

Returns an iterator over the children.

Trait Implementations

impl<'buf> Clone for ChildReader<'buf>[src]

impl<'buf> Copy for ChildReader<'buf>[src]

impl<'buf> Debug for ChildReader<'buf>[src]

impl<'buf> Eq for ChildReader<'buf>[src]

impl<'buf, 'reader> IntoIterator for &'reader ChildReader<'buf>[src]

type Item = Node<'buf>

The type of the elements being iterated over.

type IntoIter = ChildIter<'buf, 'reader>

Which kind of iterator are we turning this into?

impl<'buf> PartialEq<ChildReader<'buf>> for ChildReader<'buf>[src]

impl<'buf> StructuralEq for ChildReader<'buf>[src]

impl<'buf> StructuralPartialEq for ChildReader<'buf>[src]

Auto Trait Implementations

impl<'buf> RefUnwindSafe for ChildReader<'buf>

impl<'buf> Send for ChildReader<'buf>

impl<'buf> Sync for ChildReader<'buf>

impl<'buf> Unpin for ChildReader<'buf>

impl<'buf> UnwindSafe for ChildReader<'buf>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.