pub trait VersionSet:
Debug
+ Display
+ Clone
+ Eq {
type V: Debug + Display + Clone + Ord;
// Required methods
fn empty() -> Self;
fn singleton(v: Self::V) -> Self;
fn complement(&self) -> Self;
fn intersection(&self, other: &Self) -> Self;
fn contains(&self, v: &Self::V) -> bool;
// Provided methods
fn full() -> Self { ... }
fn union(&self, other: &Self) -> Self { ... }
fn is_disjoint(&self, other: &Self) -> bool { ... }
fn subset_of(&self, other: &Self) -> bool { ... }
}Expand description
A set of versions.
See Ranges for an implementation.
The methods with default implementations can be overwritten for better performance, but their output must be equal to the default implementation.
§Equality
It is important that the Eq trait is implemented so that if two sets contain the same
versions, they are equal under Eq. In particular, you can only use #[derive(Eq, PartialEq)]
if Eq is strictly equivalent to the structural equality, i.e. if version sets are always
stored in a canonical representations. Such problems may arise if your implementations of
complement() and intersection() do not return canonical representations.
For example, >=1,<4 || >=2,<5 and >=1,<4 || >=3,<5 are equal, because they can both be
normalized to >=1,<5.
Note that pubgrub does not know which versions actually exist for a package, the contract is about upholding the mathematical properties of set operations, assuming all versions are possible. This is required for the solver to determine the relationship of version sets to each other.
Required Associated Types§
Required Methods§
Sourcefn complement(&self) -> Self
fn complement(&self) -> Self
The set of all version that are not in this set.
Sourcefn intersection(&self, other: &Self) -> Self
fn intersection(&self, other: &Self) -> Self
The set of all versions that are in both sets.
Provided Methods§
Sourcefn full() -> Self
fn full() -> Self
The set containing all versions.
The default implementation is the complement of the empty set.
Sourcefn union(&self, other: &Self) -> Self
fn union(&self, other: &Self) -> Self
The set of all versions that are either (or both) of the sets.
The default implementation is complement of the intersection of the complements of both sets (De Morgan’s law).
Sourcefn is_disjoint(&self, other: &Self) -> bool
fn is_disjoint(&self, other: &Self) -> bool
Whether the ranges have no overlapping segments.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.