Trait TrustedContainer

Source
pub unsafe trait TrustedContainer {
    type Item: ?Sized + TrustedItem<Self>;
    type Slice: ?Sized;

    // Required methods
    fn unit_len(&self) -> usize;
    unsafe fn get_unchecked(&self, i: usize) -> &Self::Item;
    unsafe fn slice_unchecked(&self, r: Range<usize>) -> &Self::Slice;
}
Expand description

Types that can back a trusted container: it can have indices and ranges that are trusted to be in bounds.

It must have a continuously addressable range.

Required Associated Types§

Required Methods§

Source

fn unit_len(&self) -> usize

The length of the container in base item units.

Source

unsafe fn get_unchecked(&self, i: usize) -> &Self::Item

Source

unsafe fn slice_unchecked(&self, r: Range<usize>) -> &Self::Slice

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl TrustedContainer for str

Source§

type Item = Character

Source§

type Slice = str

Source§

fn unit_len(&self) -> usize

Source§

unsafe fn get_unchecked(&self, i: usize) -> &Self::Item

Source§

unsafe fn slice_unchecked(&self, r: Range<usize>) -> &Self::Slice

Source§

impl TrustedContainer for String

Available on crate feature std only.
Source§

type Item = Character

Source§

type Slice = str

Source§

fn unit_len(&self) -> usize

Source§

unsafe fn get_unchecked(&self, i: usize) -> &Self::Item

Source§

unsafe fn slice_unchecked(&self, r: Range<usize>) -> &Self::Slice

Source§

impl<T> TrustedContainer for [T]

Source§

type Item = T

Source§

type Slice = [T]

Source§

fn unit_len(&self) -> usize

Source§

unsafe fn get_unchecked(&self, i: usize) -> &Self::Item

Source§

unsafe fn slice_unchecked(&self, r: Range<usize>) -> &Self::Slice

Source§

impl<T> TrustedContainer for Vec<T>

Available on crate feature std only.
Source§

type Item = T

Source§

type Slice = [T]

Source§

fn unit_len(&self) -> usize

Source§

unsafe fn get_unchecked(&self, i: usize) -> &Self::Item

Source§

unsafe fn slice_unchecked(&self, r: Range<usize>) -> &Self::Slice

Source§

impl<T: TrustedContainer + ?Sized> TrustedContainer for &T

Source§

type Item = <T as TrustedContainer>::Item

Source§

type Slice = <T as TrustedContainer>::Slice

Source§

fn unit_len(&self) -> usize

Source§

unsafe fn get_unchecked(&self, i: usize) -> &Self::Item

Source§

unsafe fn slice_unchecked(&self, r: Range<usize>) -> &Self::Slice

Source§

impl<T: TrustedContainer + ?Sized> TrustedContainer for Box<T>

Available on crate feature std only.
Source§

type Item = <T as TrustedContainer>::Item

Source§

type Slice = <T as TrustedContainer>::Slice

Source§

fn unit_len(&self) -> usize

Source§

unsafe fn get_unchecked(&self, i: usize) -> &Self::Item

Source§

unsafe fn slice_unchecked(&self, r: Range<usize>) -> &Self::Slice

Implementors§