pub struct VersionRange(/* private fields */);Expand description
A set of one or more contiguous version ranges, with rez’s semantics.
Construct from a rez range string with VersionRange::parse, from a
single version with VersionRange::from_version, or from an existing
Ranges with VersionRange::from_ranges.
The inner Ranges is wrapped in Rc so that a VersionRange::clone is
a refcount bump rather than a SmallVec allocation. The solver clones
requirements (and the ranges inside them) constantly during a solve;
callgrind put SmallVec::extend + Drop at ~4 % of cycles after #66/
/#67/#68/#70/#71/#72, almost entirely from these clones.
PartialEq, Eq and Hash on Rc<T> defer to the inner T, so the
semantics are unchanged from the previous Ranges<RerVersion> field.
Implementations§
Source§impl VersionRange
impl VersionRange
Sourcepub fn any() -> Self
pub fn any() -> Self
The “any” range — contains every version. Mirrors rez’s empty-string range.
Sourcepub fn empty() -> Self
pub fn empty() -> Self
The empty range — contains no version. rez represents “empty” as None
at the API boundary, but an empty VersionRange is still useful
internally (e.g. as a from_versions accumulator).
Sourcepub fn parse(s: &str) -> Self
pub fn parse(s: &str) -> Self
Parse a rez range string such as "3", "1+<2", "==1.0", "2|6+".
|-separated alternatives are unioned together. The empty string is the
“any” range.
§Panics
Panics on a syntactically invalid range string, matching the existing
parse_version_range behaviour.
Sourcepub fn from_ranges(ranges: Ranges<RerVersion>) -> Self
pub fn from_ranges(ranges: Ranges<RerVersion>) -> Self
Wrap a raw Ranges (already produced by the requirement parser).
Sourcepub fn as_ranges(&self) -> &Ranges<RerVersion>
pub fn as_ranges(&self) -> &Ranges<RerVersion>
Borrow the underlying Ranges.
Sourcepub fn into_ranges(self) -> Ranges<RerVersion>
pub fn into_ranges(self) -> Ranges<RerVersion>
Consume into the underlying Ranges. Clones the inner if the Rc is
shared.
Sourcepub fn from_version(version: &RerVersion) -> Self
pub fn from_version(version: &RerVersion) -> Self
rez VersionRange.from_version with op=None: the “superset” range
[version, version.next()), e.g. 3 contains 3, 3.0, 3.1.4.
Sourcepub fn from_versions<I: IntoIterator<Item = RerVersion>>(versions: I) -> Self
pub fn from_versions<I: IntoIterator<Item = RerVersion>>(versions: I) -> Self
rez VersionRange.from_versions: a range containing exactly the given
versions and nothing else (e.g. ==3|==4|==5.1).
Built in a single pass via Ranges’s FromIterator rather than folding
union over singletons (which reallocated and was O(n²)) — this is hot,
it backs _PackageScope._update.
Sourcepub fn is_any(&self) -> bool
pub fn is_any(&self) -> bool
rez VersionRange.is_any: true for the range that contains all versions.
Sourcepub fn intersection(&self, other: &Self) -> Option<Self>
pub fn intersection(&self, other: &Self) -> Option<Self>
rez VersionRange.intersection (&): None if the ranges are disjoint.
Sourcepub fn inverse(&self) -> Option<Self>
pub fn inverse(&self) -> Option<Self>
rez VersionRange.inverse (~): None if and only if this is the
“any” range (whose inverse would be empty).
Sourcepub fn difference(&self, other: &Self) -> Option<Self>
pub fn difference(&self, other: &Self) -> Option<Self>
rez VersionRange.__sub__ (-): self & ~other. None if other is
the “any” range, or if the result is empty.
Sourcepub fn issuperset(&self, other: &Self) -> bool
pub fn issuperset(&self, other: &Self) -> bool
rez VersionRange.issuperset: true if other is fully contained here.
Sourcepub fn issubset(&self, other: &Self) -> bool
pub fn issubset(&self, other: &Self) -> bool
rez VersionRange.issubset: true if self is fully contained in other.
Sourcepub fn intersects(&self, other: &Self) -> bool
pub fn intersects(&self, other: &Self) -> bool
rez VersionRange.intersects: true if the ranges share any version.
Sourcepub fn contains(&self, version: &RerVersion) -> bool
pub fn contains(&self, version: &RerVersion) -> bool
rez VersionRange.contains_version / version in range.
Sourcepub fn to_versions(&self) -> Option<Vec<RerVersion>>
pub fn to_versions(&self) -> Option<Vec<RerVersion>>
rez VersionRange.to_versions: the exact (single-version) bounds present
in this range, or None if there are none. Non-exact bounds are ignored,
matching rez.
Sourcepub fn span(&self) -> Self
pub fn span(&self) -> Self
rez VersionRange.span: the smallest contiguous range that is a superset
of this range (e.g. the span of 2+<4|6+<8 is 2+<8).
Sourcepub fn split(&self) -> Vec<Self>
pub fn split(&self) -> Vec<Self>
rez VersionRange.split: one VersionRange per contiguous sub-range
(e.g. 3|5+ splits into ["3", "5+"]).
Trait Implementations§
Source§impl Clone for VersionRange
impl Clone for VersionRange
Source§fn clone(&self) -> VersionRange
fn clone(&self) -> VersionRange
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for VersionRange
impl Debug for VersionRange
Source§impl Display for VersionRange
impl Display for VersionRange
Source§impl Hash for VersionRange
impl Hash for VersionRange
Source§impl PartialEq for VersionRange
impl PartialEq for VersionRange
Source§fn eq(&self, other: &VersionRange) -> bool
fn eq(&self, other: &VersionRange) -> bool
self and other values to be equal, and is used by ==.