Reduce imports a bit via a little refactor
#![feature(maybe_uninit_ref)]
#![feature(maybe_uninit_uninit_array)]
#![cfg_attr(feature = "std", feature(read_initializer))]
+#![feature(slice_from_raw_parts)]
#![feature(slice_partition_dedup)]
#![feature(specialization)]
#![feature(trusted_len)]
@@ -26,7 +27,6 @@ use core::marker::PhantomData;
use core::mem::{self, MaybeUninit};
use core::ops::{Bound::Excluded, Bound::Included, Bound::Unbounded, RangeBounds};
use core::ptr;
-use core::slice;
#[cfg(any(feature = "std", rustdoc))]
extern crate alloc;
@@ -262,14 +262,14 @@ impl<T, const N: usize> StaticVec<T, N> {
pub fn as_slice(&self) -> &[T] {
// Safety: `self.as_ptr()` is a pointer to an array for which the first `length`
// elements are guaranteed to be initialized. Therefore this is a valid slice.
- unsafe { slice::from_raw_parts(self.as_ptr(), self.length) }
+ ptr::slice_from_raw_parts(self.as_ptr(), self.length)
}
/// Returns a mutable reference to a slice of the StaticVec's inhabited area.
#[inline(always)]
pub fn as_mut_slice(&mut self) -> &mut [T] {
// Safety: See as_slice.
- unsafe { slice::from_raw_parts_mut(self.as_mut_ptr(), self.length) }
+ ptr::slice_from_raw_parts_mut(self.as_mut_ptr(), self.length)
}
/// Returns a constant reference to the element of the StaticVec at `index`,
