#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

#1471 in Procedural macros

Download history 397/week @ 2024-01-13 802/week @ 2024-01-20 1473/week @ 2024-01-27 1493/week @ 2024-02-03 540/week @ 2024-02-10 1239/week @ 2024-02-17 594/week @ 2024-02-24 658/week @ 2024-03-02 584/week @ 2024-03-09 684/week @ 2024-03-16 1199/week @ 2024-03-23 1107/week @ 2024-03-30 907/week @ 2024-04-06 452/week @ 2024-04-13 553/week @ 2024-04-20 752/week @ 2024-04-27

2,781 downloads per month
Used in 22 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

~315–770KB
~18K SLoC