#array #auto #const

macro auto-const-array

Define a const array without specify length

5 releases

0.2.2 Apr 24, 2025
0.2.1 Jul 11, 2023
0.2.0 Nov 22, 2022
0.1.1 Nov 22, 2022
0.1.0 Nov 22, 2022

#1774 in Procedural macros

Download history 5697/week @ 2025-09-16 5583/week @ 2025-09-23 6666/week @ 2025-09-30 7107/week @ 2025-10-07 8623/week @ 2025-10-14 7987/week @ 2025-10-21 6257/week @ 2025-10-28 7486/week @ 2025-11-04 10340/week @ 2025-11-11 9872/week @ 2025-11-18 9927/week @ 2025-11-25 10917/week @ 2025-12-02 10947/week @ 2025-12-09 14253/week @ 2025-12-16 9619/week @ 2025-12-23 7867/week @ 2025-12-30

45,096 downloads per month
Used in 62 crates (2 directly)

MIT/Apache

9KB
135 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

~150–560KB
~13K SLoC