[][src]Struct core_extensions::iterators::LazyOnce

pub struct LazyOnce<F> { /* fields omitted */ }

Iterator,lazy version of [::std::iter::Once],only evaluating the item when Iterator::next is called.

Example

use core_extensions::iterators::LazyOnce;

let mut number=0;
assert_eq!(number,0);
LazyOnce::new(||{ number+=10; number });
assert_eq!(number,0);
for i in LazyOnce::new(||{ number+=10; number }) {
    assert_eq!(i,10);
}
assert_eq!(number,10);

Methods

impl<F> LazyOnce<F>[src]

pub fn new(f: F) -> Self[src]

Constructs a LazyOnce.

Trait Implementations

impl<F: Copy> Copy for LazyOnce<F>[src]

impl<F, T> Iterator for LazyOnce<F> where
    F: FnOnce() -> T, 
[src]

type Item = T

The type of the elements being iterated over.

impl<F, T> DoubleEndedIterator for LazyOnce<F> where
    F: FnOnce() -> T, 
[src]

impl<F, T> ExactSizeIterator for LazyOnce<F> where
    F: FnOnce() -> T, 
[src]

impl<F: Clone> Clone for LazyOnce<F>[src]

Auto Trait Implementations

impl<F> Unpin for LazyOnce<F> where
    F: Unpin

impl<F> Send for LazyOnce<F> where
    F: Send

impl<F> Sync for LazyOnce<F> where
    F: Sync

impl<F> UnwindSafe for LazyOnce<F> where
    F: UnwindSafe

impl<F> RefUnwindSafe for LazyOnce<F> where
    F: RefUnwindSafe

Blanket Implementations

impl<I> IteratorExt for I where
    I: Iterator
[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The error type returned when the conversion fails.

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = !

The type returned in the event of a conversion error.

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.