pub trait InternalIterator {
type Item;
// Required method
fn for_each<F>(self, f: &mut F) -> bool
where F: FnMut(Self::Item) -> bool;
// Provided methods
fn collect<F>(self) -> F
where Self: Sized,
F: FromInternalIterator<Self::Item> { ... }
fn map<R, F>(self, f: F) -> Map<Self, F>
where Self: Sized,
F: FnMut(Self::Item) -> R { ... }
}
Expand description
A trait for internal iterators. An internal iterator differs from a normal iterator in that its
iteration is controlled internally by the iterator itself, instead of externally by the calling
code. This means that instead of returning a single item on each call to next
, internal
iterators call a closure for each item on a single call to for_each
. This allows internal
operators to be implemented recursively, something that is not possible with normal iterators.
Required Associated Types§
Required Methods§
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.