Struct core_extensions::iterators::IterConstructor
source · [−]pub struct IterConstructor<F>(pub F);
iterators
only.Expand description
Uses a closure to construct Iterator
s.
This can turn this into an Iterator
(with IntoIterator::into_iter
)
multiple times if the closure is Copy
.
Example
use core_extensions::iterators::IterConstructor;
let list = vec!["hello", "world"];
let constructor = IterConstructor(||{
list.iter().enumerate().map(|(i,v)| v.repeat(i) )
});
for _ in 0..2 {
assert_eq!(
constructor.into_iter().collect::<Vec<_>>(),
["".to_string(), "world".to_string()],
);
}
Tuple Fields
0: F
Trait Implementations
sourceimpl<F: Clone> Clone for IterConstructor<F>
impl<F: Clone> Clone for IterConstructor<F>
sourcefn clone(&self) -> IterConstructor<F>
fn clone(&self) -> IterConstructor<F>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<F: Debug> Debug for IterConstructor<F>
impl<F: Debug> Debug for IterConstructor<F>
sourceimpl<F, I> IntoIterator for IterConstructor<F> where
F: FnOnce() -> I,
I: IntoIterator,
impl<F, I> IntoIterator for IterConstructor<F> where
F: FnOnce() -> I,
I: IntoIterator,
type Item = <I as IntoIterator>::Item
type Item = <I as IntoIterator>::Item
The type of the elements being iterated over.
type IntoIter = <I as IntoIterator>::IntoIter
type IntoIter = <I as IntoIterator>::IntoIter
Which kind of iterator are we turning this into?
impl<F: Copy> Copy for IterConstructor<F>
Auto Trait Implementations
impl<F> RefUnwindSafe for IterConstructor<F> where
F: RefUnwindSafe,
impl<F> Send for IterConstructor<F> where
F: Send,
impl<F> Sync for IterConstructor<F> where
F: Sync,
impl<F> Unpin for IterConstructor<F> where
F: Unpin,
impl<F> UnwindSafe for IterConstructor<F> where
F: UnwindSafe,
Blanket Implementations
sourceimpl<T> AsPhantomData for T where
T: ?Sized,
impl<T> AsPhantomData for T where
T: ?Sized,
sourcefn as_phantom(&self) -> PhantomData<Self>
fn as_phantom(&self) -> PhantomData<Self>
phantom
only.Gets a PhantomData<Self>
. Read more
sourcefn as_phantom_covariant(&self) -> PhantomData<fn() -> Self>
fn as_phantom_covariant(&self) -> PhantomData<fn() -> Self>
phantom
only.Gets a PhantomData<fn() -> Self>
, a covariant PhantomData
.
sourcefn as_phantom_contra(&self) -> PhantomData<fn(_: Self)>
fn as_phantom_contra(&self) -> PhantomData<fn(_: Self)>
phantom
only.Gets a PhantomData<fn(Self)>
, a contravariant PhantomData
.
sourcefn as_phantom_invariant(&self) -> PhantomData<fn(_: Self) -> Self>
fn as_phantom_invariant(&self) -> PhantomData<fn(_: Self) -> Self>
phantom
only.Gets a PhantomData<fn(Self) -> Self>
, an invariant PhantomData
.
sourceconst PHANTOM: PhantomData<Self> = PhantomData
const PHANTOM: PhantomData<Self> = PhantomData
phantom
only.Gets a PhantomData<Self>
. Read more
sourceconst PHANTOM_COVARIANT: PhantomData<fn() -> Self> = PhantomData
const PHANTOM_COVARIANT: PhantomData<fn() -> Self> = PhantomData
phantom
only.Constructs a PhantomData<fn() -> T>
, a covariant PhantomData
. Read more
sourceconst PHANTOM_CONTRA: PhantomData<fn(_: Self)> = PhantomData
const PHANTOM_CONTRA: PhantomData<fn(_: Self)> = PhantomData
phantom
only.Gets a PhantomData<fn(Self)>
, a contravariant PhantomData
. Read more
sourceconst PHANTOM_INVARIANT: PhantomData<fn(_: Self) -> Self> = PhantomData
const PHANTOM_INVARIANT: PhantomData<fn(_: Self) -> Self> = PhantomData
phantom
only.Gets a PhantomData<fn(Self) -> Self>
, an invariant PhantomData
. Read more
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> CallExt for T where
T: ?Sized,
impl<T> CallExt for T where
T: ?Sized,
sourcefn ref_call<P>(&self, params: P) -> Self::Returns where
Self: CallRef<P>,
fn ref_call<P>(&self, params: P) -> Self::Returns where
Self: CallRef<P>,
callable
only.For calling CallRef::ref_call_
,
with the ability to specify the types of the arguments.. Read more