Crates.io | multidimension |
lib.rs | multidimension |
version | 0.3.3 |
source | src |
created_at | 2023-09-06 03:17:50.445202 |
updated_at | 2023-11-14 15:23:49.258078 |
description | High-level manipulation of multi-dimensional arrays. |
homepage | https://github.com/apt1002/multidimension |
repository | https://github.com/apt1002/multidimension |
max_upload_size | |
id | 964987 |
size | 93,392 |
A pure-Rust library providing high-level manipulation of multi-dimensional arrays.
The focus of this library is to provide an easy and bug-free way of programming with multi-dimensional arrays. In particular:
std::iter
.multidimension::Index
, and you are encouraged to make type distinctions among
array indices.More can be found in the docs.
let a: Array<_, _> = usize::all(3).map(|x| x + 10).diagonal().collect();
assert_eq!(a.as_ref(), [
10, 0, 0,
0, 11, 0,
0, 0, 12,
]);
let a: Array<bool, usize> = Array::new((), [2, 1]);
let b: Array<usize, &str> = Array::new(3, ["apple", "body", "crane"]);
let ab: Array<bool, &str> = a.compose(b).collect();
assert_eq!(ab.as_ref(), ["crane", "body"])
let a: Array<usize, usize> = usize::all(3).collect();
let b: Array<usize, &str> = Array::new(3, ["apple", "body", "crane"]);
let ab: Array<usize, (usize, &str)> = a.zip(b).collect();
assert_eq!(ab.as_ref(), [
(0, "apple"),
(1, "body"),
(2, "crane"),
]);
let a: Array<_, _> = <(usize, usize)>::all((3, 2)).collect();
assert_eq!(a.as_ref(), [
(0, 0), (0, 1),
(1, 0), (1, 1),
(2, 0), (2, 1),
]);
let b: Array<_, _> = a.transpose::<(), usize, usize, ()>().collect();
assert_eq!(b.as_ref(), [
(0, 0), (1, 0), (2, 0),
(0, 1), (1, 1), (2, 1),
]);
are welcome!
© 2023 Alistair Turnbull. Please use multidimension at minworks dot co dot uk.