Skip to content

Commit

Permalink
Add SliceOps::as_array_chunks(_mut) (#1005)
Browse files Browse the repository at this point in the history
Adds thunks for the `slice_to_chunks`/`slice_to_chunks_mut` static
functions as provided methods of the `SliceOps` trait.
  • Loading branch information
tarcieri authored Dec 30, 2023
1 parent 8646acb commit 3d3ee5c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions hybrid-array/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,19 @@ pub trait SliceOps<T>:
+ IndexMut<usize>
+ IndexMut<Range<usize>>
{
/// Splits the shared slice into a slice of `N`-element arrays.
///
/// See [`slice_as_chunks`] for more information.
fn as_array_chunks<N: ArraySize>(&self) -> (&[Array<T, N>], &[T]) {
slice_as_chunks(self.as_ref())
}

/// Splits the exclusive slice into a slice of `N`-element arrays.
///
/// See [`slice_as_chunks_mut`] for more information.
fn as_array_chunks_mut<N: ArraySize>(&mut self) -> (&mut [Array<T, N>], &mut [T]) {
slice_as_chunks_mut(self.as_mut())
}
}

impl<T> SliceOps<T> for [T] {}
Expand Down

0 comments on commit 3d3ee5c

Please sign in to comment.