pub trait Set {
type Elem: Eq + ?Sized;
// Required methods
fn bounded_cardinality(&self) -> BoundedCardinality;
fn contains<Q>(&self, elem: &Q) -> bool
where Q: Borrow<Self::Elem> + Eq + ?Sized;
fn is_proper_subset(&self, val: &Self) -> bool;
fn is_subset(&self, val: &Self) -> bool;
// Provided methods
fn cardinality(&self) -> Option<Cardinality> { ... }
fn is_proper_superset(&self, val: &Self) -> bool { ... }
fn is_superset(&self, val: &Self) -> bool { ... }
fn is_proper_subset_iter<T>(&self, val: &T) -> bool
where Self::Elem: Borrow<T::Elem> + PartialEq<T::Elem>,
for<'a> &'a Self: IntoIterator<Item = &'a Self::Elem>,
T: Set + ?Sized,
T::Elem: PartialEq<Self::Elem> { ... }
fn is_subset_iter<T>(&self, val: &T) -> bool
where Self::Elem: Borrow<T::Elem> + PartialEq<T::Elem>,
for<'a> &'a Self: IntoIterator<Item = &'a Self::Elem>,
T: Set + ?Sized,
T::Elem: PartialEq<Self::Elem> { ... }
fn is_proper_superset_iter<T>(&self, val: &T) -> bool
where Self::Elem: PartialEq<T::Elem>,
T: Set + ?Sized,
for<'a> &'a T: IntoIterator<Item = &'a T::Elem>,
T::Elem: Borrow<Self::Elem> + PartialEq<Self::Elem> { ... }
fn is_superset_iter<T>(&self, val: &T) -> bool
where Self::Elem: PartialEq<T::Elem>,
T: Set + ?Sized,
for<'a> &'a T: IntoIterator<Item = &'a T::Elem>,
T::Elem: Borrow<Self::Elem> + PartialEq<Self::Elem> { ... }
}
Expand description
Represents a set according to Zermelo–Fraenkel set theory with the axiom of choice (ZFC).
Note that elements in a Set
must not be distinguishable by order or frequency, so care must be taken in its implementation if the implementing type
exposes an API that distinguishes between the order or frequency of Elem
(e.g., Vec<T>
where Elem
= T
).
Required Associated Types§
Required Methods§
sourcefn bounded_cardinality(&self) -> BoundedCardinality
fn bounded_cardinality(&self) -> BoundedCardinality
Returns the bounded cardinality of self
.
sourcefn is_proper_subset(&self, val: &Self) -> bool
fn is_proper_subset(&self, val: &Self) -> bool
Must conform to the following properties:
- Irreflexivity.
- Antisymmetry.
- Transitivity.
- ∀
a
,b
:Self
,a.is_proper_subset(b)
⇒ ∀e
:Elem
|a.contains(e)
,b.contains(e)
∧ ∃f
:Elem
,b.contains(f) && !a.contains(f)
. - ∀
a
,b
:Self
,a.is_proper_subset(b)
⇒a.is_subset(b)
. - ∀
a
,b
:Self
,a.is_proper_subset(b)
⇔b.is_proper_superset(a)
.
Provided Methods§
sourcefn cardinality(&self) -> Option<Cardinality>
fn cardinality(&self) -> Option<Cardinality>
Returns the cardinality of self
if it is known exactly.
The following property must be true:
self.cardinality().unwrap() == self.bounded_cardinality().lower()
⇔self.bounded_cardinality().lower() == self.bounded_cardinality().upper()
.
sourcefn is_proper_superset(&self, val: &Self) -> bool
fn is_proper_superset(&self, val: &Self) -> bool
Must conform to the following properties:
- Irreflexivity.
- Antisymmetry.
- Transitivity.
- ∀
a
,b
:Self
,a.is_proper_superset(b)
⇒a.is_superset(b)
.
sourcefn is_superset(&self, val: &Self) -> bool
fn is_superset(&self, val: &Self) -> bool
Must conform to the following properties:
- Reflexivity.
- Antisymmetry.
- Transitivity.
sourcefn is_proper_subset_iter<T>(&self, val: &T) -> bool
fn is_proper_subset_iter<T>(&self, val: &T) -> bool
Read Set::is_proper_subset
.
sourcefn is_subset_iter<T>(&self, val: &T) -> bool
fn is_subset_iter<T>(&self, val: &T) -> bool
Read Set::is_subset
.
sourcefn is_proper_superset_iter<T>(&self, val: &T) -> bool
fn is_proper_superset_iter<T>(&self, val: &T) -> bool
Read Set::is_proper_superset
.
Object Safety§
This trait is not object safe.
Implementations on Foreign Types§
source§impl<T> Set for BTreeSet<T>where
T: Ord,
impl<T> Set for BTreeSet<T>where
T: Ord,
source§impl<T> Set for Range<T>
impl<T> Set for Range<T>
source§impl<T> Set for RangeInclusive<T>
impl<T> Set for RangeInclusive<T>
source§impl<T, S> Set for HashSet<T, S>
Available on crate feature std
only.
impl<T, S> Set for HashSet<T, S>
Available on crate feature
std
only.