pub struct NonEmpty<T>(/* private fields */);Implementations§
Source§impl<T> NonEmpty<T>
impl<T> NonEmpty<T>
pub fn new(first: T, rest: impl IntoIterator<Item = T>) -> Self
pub fn push(&mut self, item: T)
pub fn first(&self) -> &T
pub fn last(&self) -> &T
pub fn as_slice(&self) -> &[T]
pub fn iter(&self) -> Iter<'_, T> ⓘ
pub fn map<U>(self, f: impl FnMut(T) -> U) -> NonEmpty<U>
pub fn into_vec(self) -> Vec<T>
Sourcepub fn sort_dedup(&mut self)where
T: Ord,
pub fn sort_dedup(&mut self)where
T: Ord,
Sorts and removes duplicates; at least one element always remains.
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for NonEmpty<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for NonEmpty<T>where
T: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl<T: Eq> Eq for NonEmpty<T>
Source§impl<T> IntoIterator for NonEmpty<T>
impl<T> IntoIterator for NonEmpty<T>
Source§impl<'a, T> IntoIterator for &'a NonEmpty<T>
impl<'a, T> IntoIterator for &'a NonEmpty<T>
Source§impl<T: Ord> Ord for NonEmpty<T>
impl<T: Ord> Ord for NonEmpty<T>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl<T: PartialOrd> PartialOrd for NonEmpty<T>
impl<T: PartialOrd> PartialOrd for NonEmpty<T>
impl<T: PartialEq> StructuralPartialEq for NonEmpty<T>
Auto Trait Implementations§
impl<T> Forget for NonEmpty<T>
impl<T> Freeze for NonEmpty<T>
impl<T> Move for NonEmpty<T>
impl<T> RefUnwindSafe for NonEmpty<T>where
Vec<T>: RefUnwindSafe,
impl<T> Send for NonEmpty<T>
impl<T> Sync for NonEmpty<T>
impl<T> Unpin for NonEmpty<T>
impl<T> UnsafeUnpin for NonEmpty<T>where
Vec<T>: UnsafeUnpin,
impl<T> UnwindSafe for NonEmpty<T>where
Vec<T>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more