Trait SliceIndex

Source
pub trait SliceIndex<T>: SealedSliceIndex
where T: ?Sized,
{ type Output: ?Sized; // Required methods fn get(self, slice: &T) -> Option<&Self::Output>; fn get_mut(self, slice: &mut T) -> Option<&mut Self::Output>; unsafe fn get_unchecked(self, slice: &T) -> &Self::Output; unsafe fn get_unchecked_mut(self, slice: &mut T) -> &mut Self::Output; fn index(self, slice: &T) -> &Self::Output; fn index_mut(self, slice: &mut T) -> &mut Self::Output; }
Expand description

Our own version of std::slice::SliceIndex.

Since this is a sealed trait, we need to re-define this trait. This trait itself is sealed as well.

Required Associated Types§

Source

type Output: ?Sized

The result of slicing, another slice of the same type as you started with normally.

Required Methods§

Source

fn get(self, slice: &T) -> Option<&Self::Output>

Returns a shared reference to the output at this location, if in bounds.

Source

fn get_mut(self, slice: &mut T) -> Option<&mut Self::Output>

Returns a mutable reference to the output at this location, if in bounds.

Source

unsafe fn get_unchecked(self, slice: &T) -> &Self::Output

Like SliceIndex::get but without bounds checking.

§Safety

You must guarantee the resulting slice is valid UTF-16LE, otherwise you will get undefined behaviour.

Source

unsafe fn get_unchecked_mut(self, slice: &mut T) -> &mut Self::Output

Like SliceIndex::get_mut but without bounds checking.

§Safety

You must guarantee the resulting slice is valid UTF-16LE, otherwise you will get undefined behavour.

Source

fn index(self, slice: &T) -> &Self::Output

Returns a shared reference to the output at this location, panicking if out of bounds.

Source

fn index_mut(self, slice: &mut T) -> &mut Self::Output

Returns a mutable reference to the output at this location, panicking if out of bounds.

Implementations on Foreign Types§

Source§

impl<E> SliceIndex<WStr<E>> for Range<usize>
where E: ByteOrder,

Implements substring slicing with syntax &self[begin .. end] or &mut self[begin .. end].

Source§

type Output = WStr<E>

Source§

fn get(self, slice: &WStr<E>) -> Option<&Self::Output>

Source§

fn get_mut(self, slice: &mut WStr<E>) -> Option<&mut Self::Output>

Source§

unsafe fn get_unchecked(self, slice: &WStr<E>) -> &Self::Output

Source§

unsafe fn get_unchecked_mut(self, slice: &mut WStr<E>) -> &mut Self::Output

Source§

fn index(self, slice: &WStr<E>) -> &Self::Output

Source§

fn index_mut(self, slice: &mut WStr<E>) -> &mut Self::Output

Source§

impl<E> SliceIndex<WStr<E>> for RangeFrom<usize>
where E: ByteOrder,

Implements substring slicing with syntax &self[begin ..] or &mut self[begin ..].

Source§

type Output = WStr<E>

Source§

fn get(self, slice: &WStr<E>) -> Option<&Self::Output>

Source§

fn get_mut(self, slice: &mut WStr<E>) -> Option<&mut Self::Output>

Source§

unsafe fn get_unchecked(self, slice: &WStr<E>) -> &Self::Output

Source§

unsafe fn get_unchecked_mut(self, slice: &mut WStr<E>) -> &mut Self::Output

Source§

fn index(self, slice: &WStr<E>) -> &Self::Output

Source§

fn index_mut(self, slice: &mut WStr<E>) -> &mut Self::Output

Source§

impl<E> SliceIndex<WStr<E>> for RangeFull
where E: ByteOrder,

Implments substring slicing with syntax &self[..] or &mut self[..].

Unlike other implementations this can never panic.

Source§

type Output = WStr<E>

Source§

fn get(self, slice: &WStr<E>) -> Option<&Self::Output>

Source§

fn get_mut(self, slice: &mut WStr<E>) -> Option<&mut Self::Output>

Source§

unsafe fn get_unchecked(self, slice: &WStr<E>) -> &Self::Output

Source§

unsafe fn get_unchecked_mut(self, slice: &mut WStr<E>) -> &mut Self::Output

Source§

fn index(self, slice: &WStr<E>) -> &Self::Output

Source§

fn index_mut(self, slice: &mut WStr<E>) -> &mut Self::Output

Source§

impl<E> SliceIndex<WStr<E>> for RangeInclusive<usize>
where E: ByteOrder,

Implements substring slicing with syntax &self[begin ..= end] or &mut self[begin ..= end].

Source§

type Output = WStr<E>

Source§

fn get(self, slice: &WStr<E>) -> Option<&Self::Output>

Source§

fn get_mut(self, slice: &mut WStr<E>) -> Option<&mut Self::Output>

Source§

unsafe fn get_unchecked(self, slice: &WStr<E>) -> &Self::Output

Source§

unsafe fn get_unchecked_mut(self, slice: &mut WStr<E>) -> &mut Self::Output

Source§

fn index(self, slice: &WStr<E>) -> &Self::Output

Source§

fn index_mut(self, slice: &mut WStr<E>) -> &mut Self::Output

Source§

impl<E> SliceIndex<WStr<E>> for RangeTo<usize>
where E: ByteOrder,

Implements substring slicing with syntax &self[.. end] or &mut self[.. end].

Source§

type Output = WStr<E>

Source§

fn get(self, slice: &WStr<E>) -> Option<&Self::Output>

Source§

fn get_mut(self, slice: &mut WStr<E>) -> Option<&mut Self::Output>

Source§

unsafe fn get_unchecked(self, slice: &WStr<E>) -> &Self::Output

Source§

unsafe fn get_unchecked_mut(self, slice: &mut WStr<E>) -> &mut Self::Output

Source§

fn index(self, slice: &WStr<E>) -> &Self::Output

Source§

fn index_mut(self, slice: &mut WStr<E>) -> &mut Self::Output

Source§

impl<E> SliceIndex<WStr<E>> for RangeToInclusive<usize>
where E: ByteOrder,

Implements substring slicing with syntax &self[..= end] or &mut self[..= end].

Source§

type Output = WStr<E>

Source§

fn get(self, slice: &WStr<E>) -> Option<&Self::Output>

Source§

fn get_mut(self, slice: &mut WStr<E>) -> Option<&mut Self::Output>

Source§

unsafe fn get_unchecked(self, slice: &WStr<E>) -> &Self::Output

Source§

unsafe fn get_unchecked_mut(self, slice: &mut WStr<E>) -> &mut Self::Output

Source§

fn index(self, slice: &WStr<E>) -> &Self::Output

Source§

fn index_mut(self, slice: &mut WStr<E>) -> &mut Self::Output

Implementors§