#data-structure #no-std #array

no-std array-macro

Array multiple elements constructor syntax

5 stable releases

2.1.5 May 29, 2022
2.1.1 Jan 27, 2022
2.1.0 Mar 26, 2021
2.0.0 Dec 31, 2020
0.1.2 Nov 18, 2017

#114 in Data structures

Download history 21863/week @ 2023-06-01 23961/week @ 2023-06-08 24194/week @ 2023-06-15 23455/week @ 2023-06-22 21255/week @ 2023-06-29 24031/week @ 2023-07-06 21237/week @ 2023-07-13 23288/week @ 2023-07-20 25404/week @ 2023-07-27 23582/week @ 2023-08-03 22845/week @ 2023-08-10 24712/week @ 2023-08-17 32883/week @ 2023-08-24 24535/week @ 2023-08-31 22844/week @ 2023-09-07 14860/week @ 2023-09-14

100,132 downloads per month
Used in 135 crates (15 directly)

MIT/Apache

10KB
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