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§
source§impl VersionReq
impl VersionReq
sourcepub const STAR: VersionReq = _
pub const STAR: VersionReq = _
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.
sourcepub fn parse(text: &str) -> Result<VersionReq, Error>
pub fn parse(text: &str) -> Result<VersionReq, 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.
Trait Implementations§
source§impl Clone for VersionReq
impl Clone for VersionReq
source§fn clone(&self) -> VersionReq
fn clone(&self) -> VersionReq
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for VersionReq
impl Debug for VersionReq
source§impl Default for VersionReq
impl Default for VersionReq
The default VersionReq is the same as VersionReq::STAR
.
source§fn default() -> VersionReq
fn default() -> VersionReq
source§impl<'de> Deserialize<'de> for VersionReq
impl<'de> Deserialize<'de> for VersionReq
source§fn deserialize<D>(
deserializer: D,
) -> Result<VersionReq, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<VersionReq, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
source§impl Display for VersionReq
impl Display for VersionReq
source§impl FromIterator<Comparator> for VersionReq
impl FromIterator<Comparator> for VersionReq
source§fn from_iter<I>(iter: I) -> VersionReqwhere
I: IntoIterator<Item = Comparator>,
fn from_iter<I>(iter: I) -> VersionReqwhere
I: IntoIterator<Item = Comparator>,
source§impl FromStr for VersionReq
impl FromStr for VersionReq
source§impl Hash for VersionReq
impl Hash for VersionReq
source§impl PartialEq for VersionReq
impl PartialEq for VersionReq
source§impl Serialize for VersionReq
impl Serialize for VersionReq
source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl Eq for VersionReq
impl StructuralPartialEq for VersionReq
Auto Trait Implementations§
impl Freeze for VersionReq
impl RefUnwindSafe for VersionReq
impl Send for VersionReq
impl Sync for VersionReq
impl Unpin for VersionReq
impl UnwindSafe for VersionReq
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more