[][src]Struct core_extensions::iterators::IterConstructor

pub struct IterConstructor<F> {
    pub f: F,
}

Constructs Iterators using a closure.

This can construct an Iterator (with IntoIterator::into_iter) multiple times if the closure is Copy.

Closures can be Copy and/or Clone since Rust 1.26.

Example

This example only runs from Rust 1.26 onwards,

use core_extensions::iterators::IterConstructor;

let list=vec!["hello","world"];

let constructor=IterConstructor::new(||{
   list.iter().enumerate().map(|(i,v)| v.repeat(i) )
});

let list_2=vec!["".to_string(),"world".into()];

assert_eq!(constructor.into_iter().collect::<Vec<_>>() , list_2);

assert_eq!(constructor.into_iter().collect::<Vec<_>>() , list_2);

Fields

f: F

The closure.

Implementations

impl<F> IterConstructor<F>[src]

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

Constructs an IterConstructor.

Trait Implementations

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

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

impl<F, I> IntoIterator for IterConstructor<F> where
    F: FnOnce() -> I,
    I: Iterator
[src]

type Item = I::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

Auto Trait Implementations

impl<F> RefUnwindSafe for IterConstructor<F> where
    F: RefUnwindSafe
[src]

impl<F> Send for IterConstructor<F> where
    F: Send
[src]

impl<F> Sync for IterConstructor<F> where
    F: Sync
[src]

impl<F> Unpin for IterConstructor<F> where
    F: Unpin
[src]

impl<F> UnwindSafe for IterConstructor<F> where
    F: UnwindSafe
[src]

Blanket Implementations

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

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

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

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

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

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

type Owned = T

The resulting type after obtaining ownership.

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

type Error = Infallible

The type returned in the event of a conversion error.

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