orx_iterable/sources/
repeat_n.rsuse crate::Iterable;
pub struct RepeatN<T>
where
T: Clone,
{
pub(crate) value: T,
pub(crate) count: usize,
}
impl<T> Iterable for RepeatN<T>
where
T: Clone,
{
type Item = T;
type Iter = core::iter::RepeatN<T>;
fn iter(&self) -> Self::Iter {
core::iter::repeat_n(self.value.clone(), self.count)
}
}
impl<T> Iterable for core::iter::RepeatN<T>
where
T: Clone,
{
type Item = T;
type Iter = core::iter::RepeatN<T>;
fn iter(&self) -> Self::Iter {
self.clone()
}
}
pub fn repeat_n<T>(value: T, count: usize) -> RepeatN<T>
where
T: Clone,
{
RepeatN { value, count }
}