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

Fields

comparators: Vec<Comparator>

Implementations

impl VersionReq

const STAR: Self = _;

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.

fn parse(text: &str) -> Result<Self, Error>

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.

fn matches(&self, version: &Version) -> bool

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

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

Returns the argument unchanged.

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

type Owned = T;
fn to_owned(&self) -> T
fn 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) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses 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>