Function repeat_n
fn repeat_n<T: Clone>(element: T, count: usize) -> RepeatN<T>
Creates a new iterator that repeats a single element a given number of times.
The repeat_n() function repeats a single value exactly n times.
This is very similar to using repeat() with [Iterator::take()],
but repeat_n() can return the original value, rather than always cloning.
Examples
Basic usage:
use iter;
// four of the number four:
let mut four_fours = repeat_n;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
// no more fours
assert_eq!;
For non-Copy types,
use iter;
let v: = Vecwith_capacity;
let mut it = repeat_n;
for i in 0..4
// ... but the last item is the original one
let last = it.next.unwrap;
assert_eq!;
assert_eq!;
// ... and now we're done
assert_eq!;