8 releases (5 stable)

1.0.4 Jul 5, 2019
1.0.3 Dec 31, 2018
1.0.2 Apr 9, 2018
1.0.0 Nov 30, 2017
0.1.1 Aug 1, 2017

#56 in Data structures

Download history 933/week @ 2019-07-28 805/week @ 2019-08-04 1058/week @ 2019-08-11 1118/week @ 2019-08-18 1142/week @ 2019-08-25 1012/week @ 2019-09-01 1362/week @ 2019-09-08 910/week @ 2019-09-15 900/week @ 2019-09-22 945/week @ 2019-09-29 1030/week @ 2019-10-06 870/week @ 2019-10-13 720/week @ 2019-10-20 880/week @ 2019-10-27 922/week @ 2019-11-03

3,964 downloads per month
Used in 42 crates (4 directly)

MIT/Apache

8KB
59 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