Crates.io | array-helpers |
lib.rs | array-helpers |
version | 0.0.1 |
source | src |
created_at | 2019-06-16 00:21:13.141162 |
updated_at | 2019-06-16 00:21:13.141162 |
description | Basic length-generic operations on arrays. |
homepage | |
repository | https://github.com/finegeometer/array-helpers-rs |
max_upload_size | |
id | 141423 |
size | 33,510 |
Basic length-generic operations on arrays.
This crate provides utilities for initializing, consuming, and transforming arrays. All methods are length-generic.
This crate uses the extremely new const_generics
feature.
As such, it requires nightly Rust.
let arr: [[usize; 3]; 2] = array_helpers::new(|i| array_helpers::new(|j| 3*i + j));
assert_eq!(arr, [[0,1,2],[3,4,5]]);
let arr = arr.transpose();
assert_eq!(arr, [[0,3],[1,4],[2,5]]);
let arr = arr.map(|[a,b]| (a,b));
assert_eq!(arr, [(0,3),(1,4),(2,5)]);
let (arr1, arr2) = arr.unzip();
assert_eq!(arr1, [0,1,2]);
assert_eq!(arr2, [3,4,5]);
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.