Expand description
This crate defines array!
and other macros that can construct arrays.
Use simple syntax, make it more complex as requirements change.
array!
macro constructs arrays by repeating expression execution, possibly with enumeration bound to provided pattern.
Examples
let values: [f32; 2] = array![random(); 2];
This also means that expression type may not be Copy
or event Clone
.
let values = array![Mutex::new(1); 2];
See more examples in the array!
macro documentation.
collect_array!
macro constructs arrays by repeating expression execution with elements from iterators bound to provided patterns.
Examples
let opt = collect_array![x in 1.., y in 2.. => x + y; where x * y > 10; 3];
assert_eq!(opt, Some([7, 9, 11]));
let values = collect_array![(x, y) in [(1, 2), (3, 4), (5, 6)] => x + y; 3];
assert_eq!(values, Some([3, 7, 11]));
See more examples in the collect_array!
macro documentation.
Macros
Constructs arrays by repeating expression execution, possibly with enumeration bound to provided pattern.
Constructs arrays by repeating expression with elements from iterators bound to provided patterns.