[−][src]Struct core_extensions::iterators::IterCloner
Constructs an Iterator by cloning the one it references,if the Iterator is Clone.
Constructs an Iterator inside IntoIterator::into_iter by cloning the one it references.
To construct this from an iterator value use this macro ,
Closures can be Copy and/or Clone since Rust 1.26 ,this affects iterators since most iterator methods take closures.
Example
This example only runs from Rust 1.26 onwards,
use core_extensions::iterators::IterCloner; let list=vec!["hello","awesome","world"]; let iter=list.iter().map(|v|v.len()).filter(|&v| v<6 ); { let iter_clone=IterCloner::new(&iter); for _ in 0..2{ assert_eq!(iter_clone.into_iter().collect::<Vec<_>>(),vec![5,5]); } } assert_eq!(iter.into_iter().collect::<Vec<_>>(),vec![5,5]);
Fields
iter: &'a I
The iterator being cloned.
Methods
impl<'a, I: 'a> IterCloner<'a, I> where
I: Iterator + Clone,
[src]
I: Iterator + Clone,
Trait Implementations
impl<'a, I: 'a> IntoIterator for IterCloner<'a, I> where
I: Iterator + Clone,
[src]
I: Iterator + Clone,
type Item = I::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<'a, I> Clone for IterCloner<'a, I>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'a, I> Copy for IterCloner<'a, I>
[src]
Auto Trait Implementations
impl<'a, I> Send for IterCloner<'a, I> where
I: Sync,
I: Sync,
impl<'a, I> Sync for IterCloner<'a, I> where
I: Sync,
I: Sync,
impl<'a, I> Unpin for IterCloner<'a, I>
impl<'a, I> UnwindSafe for IterCloner<'a, I> where
I: RefUnwindSafe,
I: RefUnwindSafe,
impl<'a, I> RefUnwindSafe for IterCloner<'a, I> where
I: RefUnwindSafe,
I: RefUnwindSafe,
Blanket Implementations
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The error type returned when the conversion fails.
fn try_into(Self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
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?
fn into_iter(self) -> I
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,