stride
This crate provides a slice-like Stride<T, S> type where elements are
spaced a constant S elements in memory.
For example, given an underlying slice &[1, 2, 3, 4, 5, 6], the elements
&[1, 3, 5] are a strided slice with a stride of 2. This crate makes use of
const generics to provide the stride value S at compile time so that there
is no runtime memory overhead to strided slices; Stride takes up the same
amount of space as a slice.
Many slice-like operations are implemented for Stride including iteration
and indexing. Method names are similar to those of the slice type.
Where you want a strided slice use:
::new()``Stride::newto construct a&Stride<T, S>``Stridethat wraps a&[T]``slice.::new_mut()``Stride::new_mutto construct a&mut Stride<T, S>``Stridethat wraps a&mut [T]``slice.
use Stride;
// The underlying data.
let data = &mut ;
// Create a strided slice with a stride of `2` referring to
// elements `1`, `7`, and `5`.
let stride = new_mut;
assert_eq!;
// We can use indexing to view values ..
assert_eq!;
assert_eq!;
// .. or modify them.
stride = 3;
assert_eq!;
assert_eq!;
🦀 MSRV
This crate supports Rust 1.83 and above.
License
This project is distributed under the terms of both the MIT license and the Apache License (Version 2.0).
See LICENSE-APACHE and LICENSE-MIT for details.