pub struct LazyList<T, I> { /* private fields */ }
Expand description
A lazily-populated list.
See the crate-level documentation for more information.
Implementations§
source§impl<T, I> LazyList<T, I>
impl<T, I> LazyList<T, I>
sourcepub const fn new(iterator: I) -> LazyList<T, I>
pub const fn new(iterator: I) -> LazyList<T, I>
Creates an LazyList
from an iterator. The resulting LazyList
conceptually contains the list of elements that the iterator would
produce.
Equivalent to crate::IteratorLazyExt::collect_lazy
.
sourcepub fn num_cached(&self) -> usize
pub fn num_cached(&self) -> usize
Returns the number of elements that have been produced and cached so far.
source§impl<'a, T: Send + Sync + 'a> LazyList<T, Box<dyn Iterator<Item = T> + Send + 'a>>
impl<'a, T: Send + Sync + 'a> LazyList<T, Box<dyn Iterator<Item = T> + Send + 'a>>
sourcepub fn recursive<F: FnMut(&LazyListBoxed<'a, T>, usize) -> Option<T> + Send + 'a>(
f: F
) -> Arc<LazyListBoxed<'a, T>>
pub fn recursive<F: FnMut(&LazyListBoxed<'a, T>, usize) -> Option<T> + Send + 'a>( f: F ) -> Arc<LazyListBoxed<'a, T>>
Creates a recursively-defined LazyList
. The closure should take a
reference to the LazyList
itself and an index, then return the element
at that index, or None
if there are no more elements. The closure
should only attempt to access prior elements of the LazyList
, or a
deadlock will occur.
source§impl<'a, T, I: Iterator<Item = T> + Send + 'a> LazyList<T, I>
impl<'a, T, I: Iterator<Item = T> + Send + 'a> LazyList<T, I>
sourcepub fn boxed(self) -> LazyListBoxed<'a, T>
pub fn boxed(self) -> LazyListBoxed<'a, T>
Returns a boxed version of the LazyList
. This is useful when you don’t
want to write out the iterator type as a type parameter.
source§impl<T, I: Iterator<Item = T>> LazyList<T, I>
impl<T, I: Iterator<Item = T>> LazyList<T, I>
sourcepub fn get(&self, index: usize) -> Option<&T>
pub fn get(&self, index: usize) -> Option<&T>
Returns a reference to the element at index index
, or None
if the
index is out of bounds.