Struct std::iter::Unfold

pub struct Unfold<'self, A, St> {
    priv f: &'self fn(&mut St) -> Option<A>,
    state: St,
}

An iterator which just modifies the contained state throughout iteration.

Methods

impl<'self, A, St> Unfold<'self, A, St>

fn new<'a>(initial_state: St, f: &'a fn(&mut St) -> Option<A>) -> Unfold<'a, A, St>

Creates a new iterator with the specified closure as the "iterator function" and an initial state to eventually pass to the iterator

Trait Implementations

impl<'self, A, St> Iterator<A> for Unfold<'self, A, St>

fn next(&mut self) -> Option<A>

Advance the iterator and return the next value. Return None when the end is reached.

fn size_hint(&self) -> (uint, Option<uint>)

Return a lower bound and upper bound on the remaining length of the iterator.

The common use case for the estimate is pre-allocating space to store the results.