pub trait Anonymous<Iter, In, Out, Init, Next, Context>where
Init: FnOnce(Iter) -> Context,
Next: Fn(&mut Context) -> Option<Out>,
Iter: Iterator<Item = In>,{
// Required method
fn anonymous(
self,
init_fn: Init,
next_fn: Next,
) -> AnonymousIterator<Iter, In, Out, Init, Next, Context> ⓘ;
}Expand description
Required Methods§
Sourcefn anonymous(
self,
init_fn: Init,
next_fn: Next,
) -> AnonymousIterator<Iter, In, Out, Init, Next, Context> ⓘ
fn anonymous( self, init_fn: Init, next_fn: Next, ) -> AnonymousIterator<Iter, In, Out, Init, Next, Context> ⓘ
Creates an anonymous iterator.
The iterator is defined by its behavior upon creation (AnonymousIterator::new) and when
AnonymousIterator::next are called. The former is set by a closure that receives the current
IntoIterator and returns a context (can consume data from the scope). The second closure
computes the next value from the context. The anonymous()
method resembles Iterator::scan() with the exception that the context
may depend on the calling Iterator.
§Arguments
init_fn: The closure that receives the currentIteratorand produces the initial context.next_fn: The closure that produces the next value from a mutable reference to the context.