pub struct NESet<T: Eq + Hash>(/* private fields */);Expand description
Non-empty set type.
Implementations§
Source§impl<T: Eq + Hash> NESet<T>
impl<T: Eq + Hash> NESet<T>
Sourcepub fn new(head: T, tail: Vec<T>) -> Self
pub fn new(head: T, tail: Vec<T>) -> Self
Creates a new NESet, ensuring at least one element is present.
Sourcepub fn singleton(value: T) -> Self
pub fn singleton(value: T) -> Self
Creates a new singleton NESet. Semantically equivalent to:
NESet::new(value, Vec::new());Sourcepub fn into_set(self) -> HashSet<T>
pub fn into_set(self) -> HashSet<T>
Extracts the underlying HashSet. This operation is zero-cost.
Sourcepub fn insert(&mut self, value: T) -> bool
pub fn insert(&mut self, value: T) -> bool
Adds an element to the set. If the element is already present, it is not modified.
Trait Implementations§
impl<T: Eq + Eq + Hash> Eq for NESet<T>
impl<T: Eq + Hash> StructuralPartialEq for NESet<T>
Auto Trait Implementations§
impl<T> Freeze for NESet<T>
impl<T> RefUnwindSafe for NESet<T>where
T: RefUnwindSafe,
impl<T> Send for NESet<T>where
T: Send,
impl<T> Sync for NESet<T>where
T: Sync,
impl<T> Unpin for NESet<T>where
T: Unpin,
impl<T> UnwindSafe for NESet<T>where
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