Struct lazy_list::LazyList

source ·
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>

source

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.

source

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>>

source

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>

source

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>

source

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.

source

pub fn get_mut(&mut self, index: usize) -> Option<&mut T>

Returns a mutable reference to the element at index index, or None if the index is out of bounds.

source

pub fn iter(&self) -> Iter<'_, T, I>

Returns an iterator over the elements of the LazyList.

source

pub fn iter_mut(&mut self) -> IterMut<'_, T, I>

Returns a mutable iterator over the elements of the LazyList.

Trait Implementations§

source§

impl<T: Debug, I> Debug for LazyList<T, I>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T, I: Iterator<Item = T>> Index<usize> for LazyList<T, I>

§

type Output = T

The returned type after indexing.
source§

fn index(&self, index: usize) -> &T

Performs the indexing (container[index]) operation. Read more
source§

impl<T, I: Iterator<Item = T>> IndexMut<usize> for LazyList<T, I>

source§

fn index_mut(&mut self, index: usize) -> &mut T

Performs the mutable indexing (container[index]) operation. Read more
source§

impl<'a, T, I: Iterator<Item = T>> IntoIterator for &'a LazyList<T, I>

§

type Item = &'a T

The type of the elements being iterated over.
§

type IntoIter = Iter<'a, T, I>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Iter<'a, T, I>

Creates an iterator from a value. Read more
source§

impl<'a, T, I: Iterator<Item = T>> IntoIterator for &'a mut LazyList<T, I>

§

type Item = &'a mut T

The type of the elements being iterated over.
§

type IntoIter = IterMut<'a, T, I>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> IterMut<'a, T, I>

Creates an iterator from a value. Read more
source§

impl<T, I: Iterator<Item = T>> IntoIterator for LazyList<T, I>

§

type Item = T

The type of the elements being iterated over.
§

type IntoIter = IntoIter<T, I>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> IntoIter<T, I>

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<T, I> RefUnwindSafe for LazyList<T, I>
where T: RefUnwindSafe,

§

impl<T, I> Send for LazyList<T, I>
where I: Send, T: Send,

§

impl<T, I> Sync for LazyList<T, I>
where I: Send, T: Sync + Send,

§

impl<T, I> Unpin for LazyList<T, I>
where I: Unpin, T: Unpin,

§

impl<T, I> UnwindSafe for LazyList<T, I>
where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.