Function constmuck::copying::repeat [−][src]
pub const fn repeat<T, const SIZE: usize, const ARR_LEN: usize>(
reff: &T,
bounds: TypeSize<ImplsCopy<T>, T, SIZE>
) -> [T; ARR_LEN]
Expand description
Creates a [T; ARR_LEN]
by copying from a &T
Requires that T
implements Copy + Pod
(see ImplsCopy
docs for why it requires Pod
)
To specify the length of the returned array,
TypeSize::repeat
can be used instead.
Example
use constmuck::{copying, type_size};
const PAIR: [[u8; 2]; 2] = copying::repeat(&[3, 5], type_size!([u8; 2]));
assert_eq!(PAIR, [[3, 5], [3, 5]]);
// you can use `TypeSize::repeat` like here to pass the length of the returned array.
assert_eq!(type_size!([u8; 2]).repeat::<2>(&[3, 5]), [[3, 5], [3, 5]]);