pub trait SplitFirstwhere
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§
fn split_first(self) -> Option<(Self::First, Self)>
Provided Methods§
Sourceunsafe fn split_first_unchecked(self) -> (Self::First, Self)
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]
impl<'a, T> SplitFirst for &'a [T]
Source§impl<'a, T> SplitFirst for &'a mut [T]
impl<'a, T> SplitFirst for &'a mut [T]
Source§impl<S, T> SplitFirst for (S, T)where
S: SplitFirst,
T: SplitFirst,
impl<S, T> SplitFirst for (S, T)where
S: SplitFirst,
T: SplitFirst,
type First = (<S as SplitFirst>::First, <T as SplitFirst>::First)
fn split_first(self) -> Option<(Self::First, Self)>
Implementors§
Source§impl<S, I> SplitFirst for Subset<S, I>where
I: SplitFirst + AsRef<[usize]>,
<I as SplitFirst>::First: Borrow<usize>,
S: Set + SplitAt + SplitFirst,
This impl enables Subsets of Subsets
impl<S, I> SplitFirst for Subset<S, I>where
I: SplitFirst + AsRef<[usize]>,
<I as SplitFirst>::First: Borrow<usize>,
S: Set + SplitAt + SplitFirst,
This impl enables Subsets of Subsets