| Crates.io | array_ext |
| lib.rs | array_ext |
| version | 0.4.0 |
| created_at | 2016-10-21 22:55:53.562251+00 |
| updated_at | 2022-11-11 00:24:12.78334+00 |
| description | Extra functionality for Rust arrays |
| homepage | |
| repository | https://github.com/wolfiestyle/array_ext |
| max_upload_size | |
| id | 6937 |
| size | 16,340 |
Extra functionality for Rust arrays.
The trait Array provides fixed-size array generics:
use array_ext::Array;
fn average<T: Array<f32>>(arr: T) -> f32
{
let n = arr.len() as f32;
arr.foldl(0.0, |acc, val| acc + val) / n
}
assert!((average([8.96, 3.14, 17.9]) - 10.0).abs() < f32::EPSILON);
Some methods, like zip_with, are provided by the sized ArrayN trait that allows doing full
[T; N] -> [U; N] mapping. The base Array trait can only do [T; N] -> [T; N] mapping.
This was originally made as workaround for the lack of const generics, but since v0.4 everything is implemented using const generics.