[][src]Enum ddo::core::common::Layer

pub enum Layer<'a, T> {
    Plain(Iter<'a, Node<T>>),
    Mapped(Iter<'a, T, NodeInfo>),
}

A Layer is a set of nodes that may be iterated upon.

This enum should really be considered as an opaque iterator even through the Layer type pays for itself in various ways.

  1. It facilitates the lecture of the code (it is much clearer to read that you have an access to the current and next layers than knowing you can iterate over two sets of nodes.
  2. It makes it possible to use a polymorphic return type in traits

Variants

Plain(Iter<'a, Node<T>>)

When a layer is simply backed by a vector (or a slice) of nodes

Mapped(Iter<'a, T, NodeInfo>)

When a layer is implemented as a hashmap

Trait Implementations

impl<'a, T> Iterator for Layer<'a, T>[src]

Because a Layer is an opaque iterator, it implements the standard Iterator trait from std lib.

type Item = (&'a T, &'a NodeInfo)

The type of the elements being iterated over.

fn next(&mut self) -> Option<Self::Item>[src]

Returns the next node, or None if the iteration is exhausted.

Auto Trait Implementations

impl<'a, T> RefUnwindSafe for Layer<'a, T> where
    T: RefUnwindSafe

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

impl<'a, T> Sync for Layer<'a, T> where
    T: Sync

impl<'a, T> Unpin for Layer<'a, T>

impl<'a, T> UnwindSafe for Layer<'a, T> where
    T: RefUnwindSafe

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<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

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.