#initialization #init #array #macro

nightly array_init_macro

Simple initialization macro for arrays

3 releases

0.1.2 Nov 30, 2022
0.1.1 Nov 30, 2022
0.1.0 Nov 30, 2022

#2761 in Rust patterns

MIT license

3KB

Array Init Macro

Provides a simple macro to initialize an array given a type, size and value.

Crate on Crates.io

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]];
}

No runtime deps