Struct cargo_metadata::VersionReq
source · [−]pub struct VersionReq {
pub comparators: Vec<Comparator, Global>,
}
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, Global>
Implementations
sourceimpl 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
sourceimpl Clone for VersionReq
impl Clone for VersionReq
sourcepub fn clone(&self) -> VersionReq
pub fn clone(&self) -> VersionReq
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for VersionReq
impl Debug for VersionReq
sourceimpl Default for VersionReq
impl Default for VersionReq
The default VersionReq is the same as VersionReq::STAR
.
sourcepub fn default() -> VersionReq
pub fn default() -> VersionReq
Returns the “default value” for a type. Read more
sourceimpl<'de> Deserialize<'de> for VersionReq
impl<'de> Deserialize<'de> for VersionReq
sourcepub fn deserialize<D>(
deserializer: D
) -> Result<VersionReq, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
pub fn deserialize<D>(
deserializer: D
) -> Result<VersionReq, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Display for VersionReq
impl Display for VersionReq
sourceimpl FromIterator<Comparator> for VersionReq
impl FromIterator<Comparator> for VersionReq
sourcepub fn from_iter<I>(iter: I) -> VersionReq where
I: IntoIterator<Item = Comparator>,
pub fn from_iter<I>(iter: I) -> VersionReq where
I: IntoIterator<Item = Comparator>,
Creates a value from an iterator. Read more
sourceimpl FromStr for VersionReq
impl FromStr for VersionReq
sourceimpl Hash for VersionReq
impl Hash for VersionReq
sourceimpl PartialEq<VersionReq> for VersionReq
impl PartialEq<VersionReq> for VersionReq
sourcepub fn eq(&self, other: &VersionReq) -> bool
pub fn eq(&self, other: &VersionReq) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcepub fn ne(&self, other: &VersionReq) -> bool
pub fn ne(&self, other: &VersionReq) -> bool
This method tests for !=
.
sourceimpl Serialize for VersionReq
impl Serialize for VersionReq
sourcepub fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
pub fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Eq for VersionReq
impl StructuralEq for VersionReq
impl StructuralPartialEq for VersionReq
Auto Trait Implementations
impl RefUnwindSafe for VersionReq
impl Send for VersionReq
impl Sync for VersionReq
impl Unpin for VersionReq
impl UnwindSafe for VersionReq
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more