3 releases
0.1.2 | Nov 30, 2022 |
---|---|
0.1.1 | Nov 30, 2022 |
0.1.0 | Nov 30, 2022 |
#2761 in Rust patterns
3KB
Array Init Macro
Provides a simple macro to initialize an array given a type, size and value.
use array_init_macro::arr;
fn main() {
// [1, 1, 1, 1]
let array0 = arr![u8; 4; 1];
// [1, 1, 1, 1]
let array1 = arr![u32; 4; 1];
// [Vec[1, 2], Vec[1, 2], Vec[1, 2], Vec[1, 2]]
let array2 = arr![Vec<u8>; 4; vec![1, 2]];
}