orx_iterable/transformations/
cloned.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use crate::Iterable;

/// An iterable whose iterators yield elements which are clones of references
/// that a wrapped iterable yields.
pub struct Cloned<'a, T, I>
where
    I: Iterable<Item = &'a T>,
    T: Clone + 'a,
{
    pub(crate) it: I,
}

impl<'a, T, I> Iterable for Cloned<'a, T, I>
where
    I: Iterable<Item = &'a T>,
    T: Clone + 'a,
{
    type Item = T;

    type Iter = core::iter::Cloned<I::Iter>;

    fn iter(&self) -> Self::Iter {
        self.it.iter().cloned()
    }
}