rayon::iter

Function repeat

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

Creates a parallel iterator that endlessly repeats elt (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 repeatn() 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)]);