Skip to main content

VersionRange

Struct VersionRange 

Source
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.

Implementations§

Source§

impl VersionRange

Source

pub fn any() -> Self

The “any” range — contains every version. Mirrors rez’s empty-string range.

Source

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).

Source

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.

Source

pub fn from_ranges(ranges: Ranges<RerVersion>) -> Self

Wrap a raw Ranges (already produced by the requirement parser).

Source

pub fn as_ranges(&self) -> &Ranges<RerVersion>

Borrow the underlying Ranges.

Source

pub fn into_ranges(self) -> Ranges<RerVersion>

Consume into the underlying Ranges.

Source

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.

Source

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.

Source

pub fn is_any(&self) -> bool

rez VersionRange.is_any: true for the range that contains all versions.

Source

pub fn is_empty(&self) -> bool

True if this range contains no version.

Source

pub fn intersection(&self, other: &Self) -> Option<Self>

rez VersionRange.intersection (&): None if the ranges are disjoint.

Source

pub fn union(&self, other: &Self) -> Self

rez VersionRange.union (|): always succeeds.

Source

pub fn inverse(&self) -> Option<Self>

rez VersionRange.inverse (~): None if and only if this is the “any” range (whose inverse would be empty).

Source

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.

Source

pub fn issuperset(&self, other: &Self) -> bool

rez VersionRange.issuperset: true if other is fully contained here.

Source

pub fn issubset(&self, other: &Self) -> bool

rez VersionRange.issubset: true if self is fully contained in other.

Source

pub fn intersects(&self, other: &Self) -> bool

rez VersionRange.intersects: true if the ranges share any version.

Source

pub fn contains(&self, version: &RerVersion) -> bool

rez VersionRange.contains_version / version in range.

Source

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.

Source

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).

Source

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

Source§

fn clone(&self) -> VersionRange

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for VersionRange

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for VersionRange

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Renders in rez’s compact range syntax (3, 3+<5, ==1.0, 2|6+).

Source§

impl Hash for VersionRange

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for VersionRange

Source§

fn eq(&self, other: &VersionRange) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for VersionRange

Source§

impl StructuralPartialEq for VersionRange

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V