Struct Traverse

Source
pub struct Traverse<'a, T, S> { /* private fields */ }
Expand description

Implements the traverse algorithms for an immutable reference of a Node.

Implementations§

Source§

impl<'a, T> Traverse<'a, T, Asynchronous>

Source

pub fn into_sync(self) -> Traverse<'a, T, Synchronous>

Converts the asynchronous traverse into a synchronous one.

Source§

impl<'a, T: Sync + Send + 'a> Traverse<'a, T, Asynchronous>

Source

pub async fn for_each<F>(self, f: F)
where F: Fn(&Node<T>) + Sync + Send,

Calls the given closure for each node in the tree rooted by self.

Source

pub async fn map<F, R>(self, f: F) -> TraverseOwned<R, Asynchronous>
where F: Fn(&Node<T>) -> R + Sync + Send, R: Sized + Sync + Send,

Builds a new tree by calling the given closure along the tree rooted by self following the pre-order traversal.

Source

pub async fn reduce<F, R>(self, f: F) -> R
where F: Fn(&Node<T>, Vec<R>) -> R + Sync + Send, R: Sized + Sync + Send,

Calls the given closure along the tree rooted by self, reducing it into a single value.

Source

pub async fn cascade<F, R>(self, base: R, f: F)
where F: Fn(&Node<T>, &R) -> R + Sync + Send, R: Sized + Sync + Send,

Calls the given closure along the tree rooted by self, providing the parent’s data to its children.

Source§

impl<'a, T> Traverse<'a, T, Synchronous>
where T: Sync + Send,

Source

pub fn into_async(self) -> Traverse<'a, T, Asynchronous>

Source§

impl<'a, T> Traverse<'a, T, Synchronous>

Source

pub fn for_each<F>(self, f: F) -> Self
where F: FnMut(&Node<T>),

Traverses the tree rooted by self in post-order, calling the given closure along the way.

Source

pub fn map<F, R>(self, f: F) -> TraverseOwned<R, Synchronous>
where F: FnMut(&Node<T>) -> R,

Traverses the tree rooted by self in pre-order, building a new tree by calling the given closure along the way.

Source

pub fn reduce<F, R>(self, f: F) -> R
where F: FnMut(&Node<T>, Vec<R>) -> R, R: Sized,

Traverses the tree rooted by self in post-order, calling the given closure along the way and providing its results from children to parent.

Source

pub fn cascade<F, R>(self, base: R, f: F) -> Self
where F: FnMut(&Node<T>, &R) -> R, R: Sized,

Traverses the tree rooted by self in pre-order, calling the given closure along the way and providing its result from parent to children.

Source§

impl<'a, T, S> Traverse<'a, T, S>

Source

pub fn node(&self) -> &Node<T>

Source

pub fn pre(self) -> InPre<'a, T, S>

Returns the pre-order traversal entity for the tree.

Source

pub fn post(self) -> InPost<'a, T, S>

Returns the post-order traversal entity for the tree.

Trait Implementations§

Source§

impl<'a, T, S> From<&'a Node<T>> for Traverse<'a, T, S>

Source§

fn from(node: &'a Node<T>) -> Self

Converts to this type from the input type.
Source§

impl<'a, T> From<Traverse<'a, T, Asynchronous>> for Traverse<'a, T, Synchronous>

Source§

fn from(value: Traverse<'a, T, Asynchronous>) -> Self

Converts to this type from the input type.
Source§

impl<'a, T> From<Traverse<'a, T, Synchronous>> for Traverse<'a, T, Asynchronous>
where T: Sync + Send,

Source§

fn from(value: Traverse<'a, T, Synchronous>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a, T, S> Freeze for Traverse<'a, T, S>

§

impl<'a, T, S> RefUnwindSafe for Traverse<'a, T, S>

§

impl<'a, T, S> Send for Traverse<'a, T, S>
where S: Send, T: Sync,

§

impl<'a, T, S> Sync for Traverse<'a, T, S>
where S: Sync, T: Sync,

§

impl<'a, T, S> Unpin for Traverse<'a, T, S>
where S: Unpin,

§

impl<'a, T, S> UnwindSafe for Traverse<'a, T, S>

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.