pub struct Set<T> { /* private fields */ }
Expand description
Implementations§
source§impl<T> Set<T>
impl<T> Set<T>
source§impl<T> Set<T>
impl<T> Set<T>
sourcepub fn reserve(&mut self, additional: usize)
pub fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional
more elements to be inserted in the Set
.
sourcepub fn contains<Q>(&self, value: &Q) -> bool
pub fn contains<Q>(&self, value: &Q) -> bool
Returns true if the Set
contains an element equal to the value
.
sourcepub fn get<Q>(&self, value: &Q) -> Option<&T>
pub fn get<Q>(&self, value: &Q) -> Option<&T>
Returns a reference to the element in the Set
, if any, that is equal to the value
.
sourcepub fn insert(&mut self, value: T) -> bool
pub fn insert(&mut self, value: T) -> bool
Adds value
to the Set
.
Returns whether the value was newly inserted:
- Returns
true
if the set did not previously contain an equal value. - Returns
false
otherwise and the entry is not updated.
sourcepub fn remove<Q>(&mut self, value: &Q) -> bool
pub fn remove<Q>(&mut self, value: &Q) -> bool
If the set contains an element equal to the value, removes it from the Set
and drops it.
Returns true
if such an element was present, otherwise false
.
sourcepub fn take<Q>(&mut self, value: &Q) -> Option<T>
pub fn take<Q>(&mut self, value: &Q) -> Option<T>
Removes and returns the element in the Set
, if any, that is equal to
the value.
The value may be any borrowed form of the set’s element type, but the ordering on the borrowed form must match the ordering on the element type.
sourcepub fn replace(&mut self, value: T) -> Option<T>
pub fn replace(&mut self, value: T) -> Option<T>
Adds a value to the Set
, replacing the existing value, if any, that is equal to the given
one. Returns the replaced value.
sourcepub fn is_disjoint(&self, other: &Set<T>) -> bool
pub fn is_disjoint(&self, other: &Set<T>) -> bool
Returns true
if self
has no elements in common with other
.
This is equivalent to checking for an empty intersection.
sourcepub fn is_subset(&self, other: &Set<T>) -> bool
pub fn is_subset(&self, other: &Set<T>) -> bool
Returns true
if the Set
is a subset of another,
i.e., other
contains at least all the values in self
.
sourcepub fn is_superset(&self, other: &Set<T>) -> bool
pub fn is_superset(&self, other: &Set<T>) -> bool
Returns true
if the Set
is a superset of another,
i.e., self
contains at least all the values in other
.
sourcepub fn difference<'a>(&'a self, other: &'a Set<T>) -> Difference<'a, T> ⓘ
pub fn difference<'a>(&'a self, other: &'a Set<T>) -> Difference<'a, T> ⓘ
Visits the values representing the difference,
i.e., the values that are in self
but not in other
.
sourcepub fn symmetric_difference<'a>(
&'a self,
other: &'a Set<T>,
) -> SymmetricDifference<'a, T> ⓘ
pub fn symmetric_difference<'a>( &'a self, other: &'a Set<T>, ) -> SymmetricDifference<'a, T> ⓘ
Visits the values representing the symmetric difference,
i.e., the values that are in self
or in other
but not in both.
sourcepub fn intersection<'a>(&'a self, other: &'a Set<T>) -> Intersection<'a, T> ⓘ
pub fn intersection<'a>(&'a self, other: &'a Set<T>) -> Intersection<'a, T> ⓘ
Visits the values representing the intersection,
i.e., the values that are both in self
and other
.
When an equal element is present in self
and other
then the resulting Intersection
may yield references to
one or the other. This can be relevant if T
contains fields which
are not compared by its Eq
implementation, and may hold different
value between the two equal copies of T
in the two sets.
Trait Implementations§
source§impl<'a, T> Extend<&'a T> for Set<T>
impl<'a, T> Extend<&'a T> for Set<T>
source§fn extend<Iter>(&mut self, iter: Iter)where
Iter: IntoIterator<Item = &'a T>,
fn extend<Iter>(&mut self, iter: Iter)where
Iter: IntoIterator<Item = &'a T>,
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl<T> Extend<T> for Set<T>
impl<T> Extend<T> for Set<T>
source§fn extend<Iter>(&mut self, iter: Iter)where
Iter: IntoIterator<Item = T>,
fn extend<Iter>(&mut self, iter: Iter)where
Iter: IntoIterator<Item = T>,
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl<T> FromIterator<T> for Set<T>
impl<T> FromIterator<T> for Set<T>
source§impl<'a, T> IntoIterator for &'a Set<T>
impl<'a, T> IntoIterator for &'a Set<T>
source§impl<T> IntoIterator for Set<T>
impl<T> IntoIterator for Set<T>
impl<T> Eq for Set<T>
Auto Trait Implementations§
impl<T> Freeze for Set<T>
impl<T> RefUnwindSafe for Set<T>where
T: RefUnwindSafe,
impl<T> Send for Set<T>where
T: Send,
impl<T> Sync for Set<T>where
T: Sync,
impl<T> Unpin for Set<T>where
T: Unpin,
impl<T> UnwindSafe for Set<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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more