Module nonempty_collections::array
source · Expand description
Extends non-zero length arrays with conversion methods to non-empty collections.
Since fixed-size arrays are by definition already not empty, they aren’t
given a special wrapper type like crate::NEVec
. Instead, we enable them
to be easily iterated over in a compatible way:
use nonempty_collections::*;
let a: [u32; 4] = [1, 2, 3, 4];
let v: NEVec<_> = a.into_nonempty_iter().map(|n| n + 1).collect();
assert_eq!(nev![2, 3, 4, 5], v);
See NonEmptyArrayExt
for more conversions.
§Caveats
These extensions are only provided for arrays up to size 32.
Structs§
- Non-empty iterator for arrays with length > 0.
Traits§
- Provides extension methods for non-empty arrays.