Skip to content

Commit

Permalink
Remove redundant core::slice prefixes (#62)
Browse files Browse the repository at this point in the history
We import `core::slice`, so we can just use `slice`.

The previous redundant import now triggers a warning on nightly.
  • Loading branch information
tarcieri authored Mar 5, 2024
1 parent 10e6dff commit ced37f0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,28 +355,28 @@ where
#[inline]
pub fn cast_slice_to_core(slice: &[Self]) -> &[[T; N]] {
// SAFETY: `Self` is a `repr(transparent)` newtype for `[T; N]`
unsafe { core::slice::from_raw_parts(slice.as_ptr().cast(), slice.len()) }
unsafe { slice::from_raw_parts(slice.as_ptr().cast(), slice.len()) }
}

/// Transform mutable slice to mutable slice of core array type.
#[inline]
pub fn cast_slice_to_core_mut(slice: &mut [Self]) -> &mut [[T; N]] {
// SAFETY: `Self` is a `repr(transparent)` newtype for `[T; N]`
unsafe { core::slice::from_raw_parts_mut(slice.as_mut_ptr().cast(), slice.len()) }
unsafe { slice::from_raw_parts_mut(slice.as_mut_ptr().cast(), slice.len()) }
}

/// Transform slice to slice of core array type.
#[inline]
pub fn cast_slice_from_core(slice: &[[T; N]]) -> &[Self] {
// SAFETY: `Self` is a `repr(transparent)` newtype for `[T; N]`
unsafe { core::slice::from_raw_parts(slice.as_ptr().cast(), slice.len()) }
unsafe { slice::from_raw_parts(slice.as_ptr().cast(), slice.len()) }
}

/// Transform mutable slice to mutable slice of core array type.
#[inline]
pub fn cast_slice_from_core_mut(slice: &mut [[T; N]]) -> &mut [Self] {
// SAFETY: `Self` is a `repr(transparent)` newtype for `[T; N]`
unsafe { core::slice::from_raw_parts_mut(slice.as_mut_ptr().cast(), slice.len()) }
unsafe { slice::from_raw_parts_mut(slice.as_mut_ptr().cast(), slice.len()) }
}
}

Expand Down

0 comments on commit ced37f0

Please sign in to comment.