Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/finegeometer/array-helpers-rs
Basic length-generic operations on arrays.
https://github.com/finegeometer/array-helpers-rs
Last synced: 3 months ago
JSON representation
Basic length-generic operations on arrays.
- Host: GitHub
- URL: https://github.com/finegeometer/array-helpers-rs
- Owner: finegeometer
- Created: 2019-06-16T00:00:35.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-06-16T00:09:00.000Z (over 5 years ago)
- Last Synced: 2024-08-10T19:28:46.087Z (6 months ago)
- Language: Rust
- Size: 6.84 KB
- Stars: 8
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# array-helpers
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]);
```## License
Licensed under either of
* Apache License, Version 2.0
([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license
([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)at your option.
## Contribution
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.