pub struct VecSet<T: Eq> { /* private fields */ }Expand description
A set backed by a VecMap where the value for each key is ().
Implementations§
Source§impl<T: Eq> VecSet<T>
impl<T: Eq> VecSet<T>
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates a VecSet that can hold capacity elements without reallocating
Sourcepub const unsafe fn from_map_unchecked(map: VecMap<T, ()>) -> VecSet<T>
pub const unsafe fn from_map_unchecked(map: VecMap<T, ()>) -> VecSet<T>
Please only use this method to create set literals if the “macros” feature is unavailable to you “macros” provides safe, checked alternatives to initialize linear maps with compile time checking of the invariants of each type.
Creates a new VecSet from the supplied VecMap.
SAFETY: improper use of this method - initializing with duplicate values - will NOT create memory unsafety, but will result in every identical value beyond the first never getting accessed as LinearMaps short circuit on the first match.
Sourcepub fn insert(&mut self, value: T) -> bool
pub fn insert(&mut self, value: T) -> bool
Adds a value to the set. If the set did not previously contain this value, true is returned. If the set already contained this value, false is returned, and the set is not modified: original value is not replaced, and the value passed as argument is dropped.
Sourcepub fn remove(&mut self, value: &T) -> Option<T>
pub fn remove(&mut self, value: &T) -> Option<T>
Attempts to remove the referenced value from the set, returning None if it is not present.