pub struct ThinSlicePtr<'a, T> { /* private fields */ }Expand description
Conceptually equivalent to &'a [T] but with length information cut out for performance
reasons.
Because this type does not store the length of the slice, it is unable to do any sort of bounds
checking. As such, only Self::get_unchecked() is available for indexing into the slice,
where the user is responsible for checking the bounds.
When compiled in debug mode (#[cfg(debug_assertion)]), this type will store the length of the
slice and perform bounds checking in Self::get_unchecked().
§Example
let slice: &[u32] = &[2, 4, 8];
let thin_slice = ThinSlicePtr::from(slice);
assert_eq!(*unsafe { thin_slice.get_unchecked(0) }, 2);
assert_eq!(*unsafe { thin_slice.get_unchecked(1) }, 4);
assert_eq!(*unsafe { thin_slice.get_unchecked(2) }, 8);Implementations§
Source§impl<'a, T> ThinSlicePtr<'a, T>
impl<'a, T> ThinSlicePtr<'a, T>
Sourcepub unsafe fn get_unchecked(&self, index: usize) -> &'a T
pub unsafe fn get_unchecked(&self, index: usize) -> &'a T
Trait Implementations§
Source§impl<'a, T> Clone for ThinSlicePtr<'a, T>
impl<'a, T> Clone for ThinSlicePtr<'a, T>
Source§impl<'a, T> From<&'a [T]> for ThinSlicePtr<'a, T>
impl<'a, T> From<&'a [T]> for ThinSlicePtr<'a, T>
impl<'a, T> Copy for ThinSlicePtr<'a, T>
Auto Trait Implementations§
impl<'a, T> Freeze for ThinSlicePtr<'a, T>
impl<'a, T> RefUnwindSafe for ThinSlicePtr<'a, T>where
T: RefUnwindSafe,
impl<'a, T> !Send for ThinSlicePtr<'a, T>
impl<'a, T> !Sync for ThinSlicePtr<'a, T>
impl<'a, T> Unpin for ThinSlicePtr<'a, T>
impl<'a, T> UnwindSafe for ThinSlicePtr<'a, T>where
T: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more