pub struct VersionReq {
    pub comparators: Vec<Comparator>,
}
Expand description

SemVer version requirement describing the intersection of some version comparators, such as >=1.2.3, <1.8.

Syntax

  • Either * (meaning “any”), or one or more comma-separated comparators.

  • A Comparator is an operator (Op) and a partial version, separated by optional whitespace. For example >=1.0.0 or >=1.0.

  • Build metadata is syntactically permitted on the partial versions, but is completely ignored, as it’s never relevant to whether any comparator matches a particular version.

  • Whitespace is permitted around commas and around operators. Whitespace is not permitted within a partial version, i.e. anywhere between the major version number and its minor, patch, pre-release, or build metadata.

Fields

comparators: Vec<Comparator>

Implementations

A VersionReq with no constraint on the version numbers it matches. Equivalent to VersionReq::parse("*").unwrap().

In terms of comparators this is equivalent to >=0.0.0.

Counterintuitively a * VersionReq does not match every possible version number. In particular, in order for any VersionReq to match a pre-release version, the VersionReq must contain at least one Comparator that has an explicit major, minor, and patch version identical to the pre-release being matched, and that has a nonempty pre-release component. Since * is not written with an explicit major, minor, and patch version, and does not contain a nonempty pre-release component, it does not match any pre-release versions.

Create VersionReq by parsing from string representation.

Errors

Possible reasons for the parse to fail include:

  • >a.b — unexpected characters in the partial version.

  • @1.0.0 — unrecognized comparison operator.

  • ^1.0.0, — unexpected end of input.

  • >=1.0 <2.0 — missing comma between comparators.

  • *.* — unsupported wildcard syntax.

Evaluate whether the given Version satisfies the version requirement described by self.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The default VersionReq is the same as VersionReq::STAR.

Returns the “default value” for a type. Read more

Deserialize this value from the given Serde deserializer. Read more

Formats the value using the given formatter. Read more

Creates a value from an iterator. Read more

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

Feeds this value into the given Hasher. Read more

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

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.