Struct VersionReq
pub struct VersionReq { pub comparators: Vec<Comparator> }
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
Comparatoris an operator (Op) and a partial version, separated by optional whitespace. For example>=1.0.0or>=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
impl VersionReq
const STAR: Self = _;A
VersionReqwith no constraint on the version numbers it matches. Equivalent toVersionReq::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 anyVersionReqto match a pre-release version, theVersionReqmust contain at least oneComparatorthat 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.fn parse(text: &str) -> Result<Self, Error>Create
VersionReqby 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.
-
fn matches(&self, version: &Version) -> boolEvaluate whether the given
Versionsatisfies the version requirement described byself.
Trait Implementations
impl Clone for VersionReq
fn clone(&self) -> Self
impl Debug for VersionReq
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Default for VersionReq
fn default() -> Self
impl Display for VersionReq
fn fmt(&self, formatter: &mut Formatter<'_>) -> Result
impl Eq for VersionReq
impl FromIterator<Comparator> for VersionReq
fn from_iter<I>(iter: I) -> Self where I: IntoIterator<Item = Comparator>,
impl FromStr for VersionReq
type Err = Error;fn from_str(text: &str) -> Result<Self, Self::Err>
impl Hash for VersionReq
fn hash<__H: Hasher>(&self, state: &mut __H)
impl PartialEq for VersionReq
fn eq(&self, other: &Self) -> bool
impl Serialize for VersionReq
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer,
impl StructuralPartialEq for VersionReq
impl<'de> Deserialize<'de> for VersionReq
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: Deserializer<'de>,