rustc_middle::ty::inherent

Trait SliceLike

pub trait SliceLike: Sized + Copy {
    type Item: Copy;
    type IntoIter: Iterator<Item = Self::Item>;

    // Required methods
    fn iter(self) -> Self::IntoIter;
    fn as_slice(&self) -> &[Self::Item];

    // Provided methods
    fn get(self, idx: usize) -> Option<Self::Item> { ... }
    fn len(self) -> usize { ... }
    fn is_empty(self) -> bool { ... }
    fn contains(self, t: &Self::Item) -> bool
       where Self::Item: PartialEq { ... }
    fn to_vec(self) -> Vec<Self::Item> { ... }
    fn last(self) -> Option<Self::Item> { ... }
    fn split_last(&self) -> Option<(&Self::Item, &[Self::Item])> { ... }
}

Required Associated Types§

type Item: Copy

type IntoIter: Iterator<Item = Self::Item>

Required Methods§

fn iter(self) -> Self::IntoIter

fn as_slice(&self) -> &[Self::Item]

Provided Methods§

fn get(self, idx: usize) -> Option<Self::Item>

fn len(self) -> usize

fn is_empty(self) -> bool

fn contains(self, t: &Self::Item) -> bool
where Self::Item: PartialEq,

fn to_vec(self) -> Vec<Self::Item>

fn last(self) -> Option<Self::Item>

fn split_last(&self) -> Option<(&Self::Item, &[Self::Item])>

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§

§

impl<'a, S> SliceLike for &'a S
where S: SliceLike,

§

type Item = <S as SliceLike>::Item

§

type IntoIter = <S as SliceLike>::IntoIter

§

fn iter(self) -> <S as SliceLike>::IntoIter

§

fn as_slice(&self) -> &[<S as SliceLike>::Item]

§

impl<'a, T> SliceLike for &'a [T]
where T: Copy,

§

type Item = T

§

type IntoIter = Copied<Iter<'a, T>>

§

fn iter(self) -> Copied<Iter<'a, T>>

§

fn as_slice(&self) -> &[T]

§

impl<'a, T, const N: usize> SliceLike for &'a [T; N]
where T: Copy,

§

type Item = T

§

type IntoIter = Copied<Iter<'a, T>>

§

fn iter(self) -> Copied<Iter<'a, T>>

§

fn as_slice(&self) -> &[T]

Implementors§

Source§

impl<'a, H, T: Copy> SliceLike for &'a RawList<H, T>

Source§

type Item = T

Source§

type IntoIter = Copied<Iter<'a, T>>