#array #const #auto

macro auto-const-array

Define a const array without specify length

4 releases

0.2.1 Jul 11, 2023
0.2.0 Nov 22, 2022
0.1.1 Nov 22, 2022
0.1.0 Nov 22, 2022

#1539 in Procedural macros

Download history 584/week @ 2024-03-13 896/week @ 2024-03-20 1359/week @ 2024-03-27 873/week @ 2024-04-03 732/week @ 2024-04-10 322/week @ 2024-04-17 793/week @ 2024-04-24 627/week @ 2024-05-01 837/week @ 2024-05-08 527/week @ 2024-05-15 564/week @ 2024-05-22 572/week @ 2024-05-29 945/week @ 2024-06-05 516/week @ 2024-06-12 295/week @ 2024-06-19 473/week @ 2024-06-26

2,295 downloads per month
Used in 26 crates (via monoio)

MIT/Apache

8KB
131 lines

Auto Const Array

Use this macro to declare a const array without specifing its length.

Crates.io MIT/Apache-2 licensed

use auto_const_array::auto_const_array;
auto_const_array! {
    // Additional attributes and docs are supported.
    /// Common array with public visibility.
    #[allow(unused)]
    pub const ARRAY_COMMON: [u8; _] = [1, 2, 4];
    /// Special array with cfg conditional compling.
    const ARRAY_WITH_ATTR: [u8; _] = [1, #[cfg(unix)] 2]
}

Dependencies

~310–770KB
~18K SLoC