2 /// An iterator that produces *n* repetitions of an element.
4 /// See [`repeat_n()`](../fn.repeat_n.html) for more information.
5 #[must_use = "iterators are lazy and do nothing unless consumed"]
7 pub struct RepeatN
<A
> {
12 /// Create an iterator that produces `n` repetitions of `element`.
13 pub fn repeat_n
<A
>(element
: A
, n
: usize) -> RepeatN
<A
>
17 RepeatN { elt: None, n: n, }
19 RepeatN { elt: Some(element), n: n, }
23 impl<A
> Iterator
for RepeatN
<A
>
28 fn next(&mut self) -> Option
<Self::Item
> {
31 self.elt
.as_ref().cloned()
38 fn size_hint(&self) -> (usize, Option
<usize>) {
39 (self.n
, Some(self.n
))
43 impl<A
> DoubleEndedIterator
for RepeatN
<A
>
47 fn next_back(&mut self) -> Option
<Self::Item
> {
52 impl<A
> ExactSizeIterator
for RepeatN
<A
>