SplitFirst

Trait SplitFirst 

Source
pub trait SplitFirst
where Self: Sized,
{ type First; // Required method fn split_first(self) -> Option<(Self::First, Self)>; // Provided method unsafe fn split_first_unchecked(self) -> (Self::First, Self) { ... } }
Expand description

Split out the first element of a collection.

Required Associated Types§

Required Methods§

Source

fn split_first(self) -> Option<(Self::First, Self)>

Provided Methods§

Source

unsafe fn split_first_unchecked(self) -> (Self::First, Self)

Split off the first element without checking if one exists.

§Safety

The collection must have at least one element otherwise this function may cause undefined behaviour if implemented.

The default implementation simply calls unwrap on split_first.

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<'a, T> SplitFirst for &'a [T]

Source§

type First = &'a T

Source§

fn split_first(self) -> Option<(Self::First, Self)>

Source§

unsafe fn split_first_unchecked(self) -> (Self::First, Self)

Source§

impl<'a, T> SplitFirst for &'a mut [T]

Source§

type First = &'a mut T

Source§

fn split_first(self) -> Option<(Self::First, Self)>

Source§

unsafe fn split_first_unchecked(self) -> (Self::First, Self)

Source§

impl<S, T> SplitFirst for (S, T)
where S: SplitFirst, T: SplitFirst,

Source§

type First = (<S as SplitFirst>::First, <T as SplitFirst>::First)

Source§

fn split_first(self) -> Option<(Self::First, Self)>

Implementors§

Source§

impl<S, I> SplitFirst for Subset<S, I>

This impl enables Subsets of Subsets

Source§

impl<S, O> SplitFirst for Chunked<S, O>

Source§

type First = S

Source§

impl<S: SplitPrefix<N> + Set, N: Copy> SplitFirst for UniChunked<S, U<N>>

Source§

type First = <S as SplitPrefix<N>>::Prefix