Skip to main content

SliceLike

Trait SliceLike 

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

    // 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§

Required Methods§

Source

fn iter(self) -> Self::IntoIter

Source

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

Provided Methods§

Source

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

Source

fn len(self) -> usize

Source

fn is_empty(self) -> bool

Source

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

Source

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

Source

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

Source

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".

Implementations on Foreign Types§

Source§

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

Source§

type Item = <S as SliceLike>::Item

Source§

type IntoIter = <S as SliceLike>::IntoIter

Source§

fn iter(self) -> Self::IntoIter

Source§

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

Source§

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

Source§

type Item = T

Source§

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

Source§

fn iter(self) -> Self::IntoIter

Source§

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

Source§

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

Source§

type Item = T

Source§

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

Source§

fn iter(self) -> Self::IntoIter

Source§

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

Implementors§