#data-structure #no-std #array

no-std array-macro

Array multiple elements constructor syntax

8 stable releases

2.1.0 Mar 26, 2021
2.0.0 Dec 31, 2020
1.0.5 May 7, 2020
1.0.4 Jul 5, 2019
0.1.2 Nov 18, 2017

#71 in Data structures

Download history 8677/week @ 2021-02-26 8556/week @ 2021-03-05 8481/week @ 2021-03-12 8917/week @ 2021-03-19 7460/week @ 2021-03-26 8111/week @ 2021-04-02 8238/week @ 2021-04-09 8314/week @ 2021-04-16 13207/week @ 2021-04-23 12867/week @ 2021-04-30 11086/week @ 2021-05-07 12512/week @ 2021-05-14 9888/week @ 2021-05-21 9743/week @ 2021-05-28 11441/week @ 2021-06-04 9477/week @ 2021-06-11

39,912 downloads per month
Used in 109 crates (9 directly)

MIT/Apache

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

# #[macro_use]
# extern crate array_macro;
# fn main() {
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