Crates.io | nslice |
lib.rs | nslice |
version | 0.2.1 |
source | src |
created_at | 2021-06-14 19:38:55.869839 |
updated_at | 2024-04-01 02:44:40.321807 |
description | Structures for interpreting slices of variable length as arrays |
homepage | |
repository | https://codeberg.org/noracodes/nslice |
max_upload_size | |
id | 410076 |
size | 12,034 |
Structures for interpreting slices of variable length as arrays.
nslice
provides MinSlice
and ExactSlice
for representing slices known to have
either exactly or at least some compile-time-known number of values.
This is useful when dealing with a slice whose length you expect to be exactly or at least some particular length; rather than making runtime checks on each access, you can check the length once and access values freely with no copying.
# use nslice::MinSlice;
let slice = &[1, 2, 3, 4, 5, 6];
let minslice: &MinSlice<_, 3> = MinSlice::from_slice(slice).unwrap();
assert_eq!(minslice.tail.len(), 3);
assert_eq!(minslice.head[0], 1);
assert_eq!(minslice.tail[2], 6);
This project supports Rust 1.56.1 and onward.
This project is licensed MIT.