Crates.io | dyn_array |
lib.rs | dyn_array |
version | 0.1.7 |
source | src |
created_at | 2022-09-12 20:13:50.194553 |
updated_at | 2022-12-04 20:22:54.101358 |
description | A simple, easy to use N-dimensional dynamic array |
homepage | |
repository | |
max_upload_size | |
id | 663989 |
size | 10,372 |
A DynArray can be constructed in two ways:
All indexing is done with std::ops::Index by passing in an array to specify which element is wanted. Ex:
let elem = arr[[10, 10, 10]];
DynArray can also be iterated over in a couple of ways. First, the data
and data_mut
provide a contiguous
slice of the elements without any regard to the dimensions of the DynArray. The provided slice can then be iterated.
There is also an Iterator
implemention for DynArray that gives you immutable access to each element while also providing
the associated index.
Ex:
// 20 by 20 integer array let mut arr = DynArray::new([20, 20], 3);
for i in arr.data_mut() { //mutable access to elements, but no indication of current index }
for (index, elem) in &arr { //immutable access to elements and the current index let [x, y] = index; }