#array #no-std

no-std array-macro

Array multiple elements constructor syntax

8 stable releases

2.1.8 Nov 8, 2023
2.1.5 May 29, 2022
2.1.3 Apr 27, 2022
2.1.1 Jan 27, 2022
0.1.2 Nov 18, 2017

#280 in Data structures

Download history 17581/week @ 2024-01-10 19892/week @ 2024-01-17 17304/week @ 2024-01-24 18816/week @ 2024-01-31 19345/week @ 2024-02-07 20998/week @ 2024-02-14 19994/week @ 2024-02-21 20742/week @ 2024-02-28 21529/week @ 2024-03-06 22971/week @ 2024-03-13 23015/week @ 2024-03-20 20922/week @ 2024-03-27 22381/week @ 2024-04-03 20801/week @ 2024-04-10 22631/week @ 2024-04-17 16765/week @ 2024-04-24

86,300 downloads per month
Used in 87 crates (13 directly)

MIT/Apache

12KB
102 lines

array-macro

Array multiple elements constructor syntax.


lib.rs:

Array multiple elements constructor syntax.

While Rust does provide those, they require copy, and you cannot obtain the index that will be created. This crate provides syntax that fixes both of those issues.

Examples

assert_eq!(array![String::from("x"); 2], [String::from("x"), String::from("x")]);
assert_eq!(array![x => x; 3], [0, 1, 2]);

No runtime deps