1
0
Fork 0
forked from wry/wry
wry/src/utils/array.rs
2022-02-19 19:41:18 +01:00

11 lines
201 B
Rust

pub fn from_fn<F, T, const N: usize>(mut cb: F) -> [T; N]
where
F: FnMut(usize) -> T,
{
let mut idx = 0;
[(); N].map(|_| {
let res = cb(idx);
idx += 1;
res
})
}