pub struct NonEmpty<C> { /* private fields */ }Expand description
A Vec<T> guaranteed to contain at least one element.
Unlike NonEmptyVec<T> in karpal-core (which has a structurally
different representation with separate head and tail fields),
NonEmpty<Vec<T>> wraps a standard Vec<T> with a refinement
invariant. Construction is only possible via try_new (which checks)
or from_parts (which requires at least one element).
Implementations§
Source§impl<T> NonEmpty<Vec<T>>
impl<T> NonEmpty<Vec<T>>
Sourcepub fn try_new(v: Vec<T>) -> Option<NonEmpty<Vec<T>>>
pub fn try_new(v: Vec<T>) -> Option<NonEmpty<Vec<T>>>
Attempt to construct a NonEmpty<Vec<T>> from a Vec<T>.
Returns None if the vector is empty.
Sourcepub fn from_parts(head: T, tail: Vec<T>) -> NonEmpty<Vec<T>>
pub fn from_parts(head: T, tail: Vec<T>) -> NonEmpty<Vec<T>>
Construct from a head element and remaining tail.
Trait Implementations§
impl<C> Eq for NonEmpty<C>where
C: Eq,
Source§impl<C> Ord for NonEmpty<C>where
C: Ord,
impl<C> Ord for NonEmpty<C>where
C: Ord,
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
Source§impl<C> PartialEq for NonEmpty<C>where
C: PartialEq,
impl<C> PartialEq for NonEmpty<C>where
C: PartialEq,
Source§impl<C> PartialOrd for NonEmpty<C>where
C: PartialOrd,
impl<C> PartialOrd for NonEmpty<C>where
C: PartialOrd,
impl<C> StructuralPartialEq for NonEmpty<C>where
C: PartialEq,
Auto Trait Implementations§
impl<C> Freeze for NonEmpty<C>where
C: Freeze,
impl<C> RefUnwindSafe for NonEmpty<C>where
C: RefUnwindSafe,
impl<C> Send for NonEmpty<C>where
C: Send,
impl<C> Sync for NonEmpty<C>where
C: Sync,
impl<C> Unpin for NonEmpty<C>where
C: Unpin,
impl<C> UnsafeUnpin for NonEmpty<C>where
C: UnsafeUnpin,
impl<C> UnwindSafe for NonEmpty<C>where
C: 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