Function repeat

Source
pub fn repeat<T: Clone + Send>(element: T) -> Repeat<T>
Expand description

Creates a parallel iterator that endlessly repeats element (by cloning it). Note that this iterator has “infinite” length, so typically you would want to use zip or take or some other means to shorten it, or consider using the repeat_n() function instead.

§Examples

use rayon::prelude::*;
use rayon::iter::repeat;
let x: Vec<(i32, i32)> = repeat(22).zip(0..3).collect();
assert_eq!(x, vec![(22, 0), (22, 1), (22, 2)]);