orx_iterable/sources/
repeat.rs1use crate::Iterable;
2
3pub struct Repeat<T>
5where
6 T: Clone,
7{
8 pub(crate) value: T,
9}
10
11impl<T> Iterable for Repeat<T>
12where
13 T: Clone,
14{
15 type Item = T;
16
17 type Iter = core::iter::Repeat<T>;
18
19 fn iter(&self) -> Self::Iter {
20 core::iter::repeat(self.value.clone())
21 }
22}
23
24impl<T> Iterable for core::iter::Repeat<T>
25where
26 T: Clone,
27{
28 type Item = T;
29
30 type Iter = core::iter::Repeat<T>;
31
32 fn iter(&self) -> Self::Iter {
33 self.clone()
34 }
35}
36
37pub fn repeat<T>(value: T) -> Repeat<T>
39where
40 T: Clone,
41{
42 Repeat { value }
43}