https://github.com/wolfiestyle/array_ext
Extra functionality for Rust arrays
https://github.com/wolfiestyle/array_ext
Last synced: 3 months ago
JSON representation
Extra functionality for Rust arrays
- Host: GitHub
- URL: https://github.com/wolfiestyle/array_ext
- Owner: wolfiestyle
- License: mit
- Created: 2016-10-20T20:22:18.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-07-24T23:15:12.000Z (almost 3 years ago)
- Last Synced: 2025-12-14T05:11:42.100Z (7 months ago)
- Language: Rust
- Size: 34.2 KB
- Stars: 0
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# array_ext
Extra functionality for Rust arrays.
[Documentation](https://docs.rs/array_ext)
## Examples
The trait `Array` provides fixed-size array generics:
```rust
use array_ext::Array;
fn average>(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.