Trait ContextIterator

Source
pub trait ContextIterator: Iterator {
    type Context;

    // Required method
    fn context(&self) -> &Self::Context;

    // Provided methods
    fn context_map<F, O>(self, map: F) -> CtxMap<Self, F> 
       where Self: Sized,
             F: Fn(&Self::Context) -> &O { ... }
    fn map_with_context<O>(
        self,
        map: fn(Self::Item, &Self::Context) -> O,
    ) -> MapCtx<Self, O> 
       where Self: Sized { ... }
    fn filter_with_context(
        self,
        filter: fn(&Self::Item, &Self::Context) -> bool,
    ) -> FilterCtx<Self> 
       where Self: Sized { ... }
    fn filter_map_with_context<O>(
        self,
        filter: fn(Self::Item, &Self::Context) -> Option<O>,
    ) -> FilterMapCtx<Self, O> 
       where Self: Sized { ... }
}
Expand description

Iterator carrying a context.

Required Associated Types§

Source

type Context

The context type.

Required Methods§

Source

fn context(&self) -> &Self::Context

Get the context.

Provided Methods§

Source

fn context_map<F, O>(self, map: F) -> CtxMap<Self, F>
where Self: Sized, F: Fn(&Self::Context) -> &O,

Get the context.

Source

fn map_with_context<O>( self, map: fn(Self::Item, &Self::Context) -> O, ) -> MapCtx<Self, O>
where Self: Sized,

Apply a map to each element in the iterator.

Source

fn filter_with_context( self, filter: fn(&Self::Item, &Self::Context) -> bool, ) -> FilterCtx<Self>
where Self: Sized,

Apply a filter over the elements of the iterator

Source

fn filter_map_with_context<O>( self, filter: fn(Self::Item, &Self::Context) -> Option<O>, ) -> FilterMapCtx<Self, O>
where Self: Sized,

Apply a filter over the elements of the iterator

Implementors§