Skip to main content

TrySlice

Trait TrySlice 

Source
trait TrySlice<T> {
    // Required methods
    fn try_mut<I>(&mut self, index: I) -> Result<&mut [T], Error>
       where I: SliceIndex<[T], Output = [T]>;
    fn try_ref<I>(&self, index: I) -> Result<&[T], Error>
       where I: SliceIndex<[T], Output = [T]>;
}
Expand description

Slicing that reports a caller buffer sized too small, rather than panicking or silently truncating.

Required Methods§

Source

fn try_mut<I>(&mut self, index: I) -> Result<&mut [T], Error>
where I: SliceIndex<[T], Output = [T]>,

Source

fn try_ref<I>(&self, index: I) -> Result<&[T], Error>
where I: SliceIndex<[T], Output = [T]>,

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T> TrySlice<T> for [T]

Source§

fn try_mut<I>(&mut self, index: I) -> Result<&mut [T], Error>
where I: SliceIndex<[T], Output = [T]>,

Source§

fn try_ref<I>(&self, index: I) -> Result<&[T], Error>
where I: SliceIndex<[T], Output = [T]>,

Implementors§