konst::iter

Function repeat

Source
pub const fn repeat<T>(val: T) -> Repeat<T>
where T: Copy,
Expand description

Const analog of core::iter::repeat, except that this requires the repeated value to impl Copy (instead of Clone).

ยงExample

use konst::iter::{self, collect_const};

const ARR: &[u8] = &collect_const!(u8 => iter::repeat(3),take(5));

assert_eq!(ARR, &[3, 3, 3, 3, 3]);