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<F, O>(self, map: F) -> MapCtx<Self, F> 
       where Self: Sized,
             F: FnMut(Self::Item, &Self::Context) -> O { ... }
    fn filter_with_context<F>(self, filter: F) -> FilterCtx<Self, F> 
       where Self: Sized,
             F: FnMut(&Self::Item, &Self::Context) -> bool { ... }
    fn filter_map_with_context<F, O>(self, filter: F) -> FilterMapCtx<Self, F> 
       where Self: Sized,
             F: FnMut(Self::Item, &Self::Context) -> Option<O> { ... }
}
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<F, O>(self, map: F) -> MapCtx<Self, F> where Self: Sized, F: FnMut(Self::Item, &Self::Context) -> O,

Apply a map to each element in the iterator.

source

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

Apply a filter over the elements of the iterator

source

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

Apply a filter over the elements of the iterator

Implementors§

source§

impl<I, Ctx> ContextIterator for WithCtx<I, Ctx>where I: Iterator,

§

type Context = Ctx

source§

impl<I, F> ContextIterator for FilterCtx<I, F>where I: ContextIterator, F: FnMut(&I::Item, &I::Context) -> bool,

source§

impl<I, F, O> ContextIterator for CtxMap<I, F>where I: ContextIterator, F: Fn(&I::Context) -> &O,

§

type Context = O

source§

impl<I, F, O> ContextIterator for FilterMapCtx<I, F>where I: ContextIterator, F: FnMut(I::Item, &I::Context) -> Option<O>,

source§

impl<I, F, O> ContextIterator for MapCtx<I, F>where I: ContextIterator, F: FnMut(I::Item, &I::Context) -> O,