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) -> VersionReq
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: &VersionReq) -> 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>,
Auto Trait Implementations
impl Freeze for VersionReq
impl RefUnwindSafe for VersionReq
impl Send for VersionReq
impl Sync for VersionReq
impl Unpin for VersionReq
impl UnsafeUnpin for VersionReq
impl UnwindSafe for VersionReq
Blanket Implementations
impl<T> Any for VersionReq
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for VersionReq
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for VersionReq
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for VersionReq
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> DeserializeOwned for VersionReq
where
T: for<'de> Deserialize<'de>,
impl<T> From<T> for VersionReq
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for VersionReq
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T> ToString for VersionReq
where
T: Display + ?Sized,
fn to_string(&self) -> String
impl<T, U> Into<U> for VersionReq
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for VersionReq
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for VersionReq
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>