pub enum VersionSpec {
}Expand description
Version specification (constraint)
Variants§
Pinned(Version)
==1.2.3
Minimum(Version)
=1.2.3
Maximum(Version)
<=1.2.3
GreaterThan(Version)
1.2.3
LessThan(Version)
<1.2.3
Range
=1.2.3,<2.0.0
Caret(Version)
^1.2.3 (caret - same major)
Tilde(Version)
~1.2.3 (tilde - same minor)
Compatible(Version)
~=1.2.3 (compatible release - Python)
Wildcard
==1.2.*
NotEqual(Version)
!=1.2.3
Complex(String)
Complex constraint we store as raw string
Any
Any version (no constraint or *)
Implementations§
Source§impl VersionSpec
impl VersionSpec
Sourcepub fn parse(s: &str) -> Result<Self, VersionError>
pub fn parse(s: &str) -> Result<Self, VersionError>
Parse a version specifier string
Sourcepub fn satisfies(&self, version: &Version) -> bool
pub fn satisfies(&self, version: &Version) -> bool
Check if a version satisfies this constraint
Sourcepub fn base_version(&self) -> Option<&Version>
pub fn base_version(&self) -> Option<&Version>
Get the base version from the spec (for comparison)
Sourcepub fn max_major(&self) -> Option<u64>
pub fn max_major(&self) -> Option<u64>
Get the maximum allowed major version (for “in range” calculation)
Sourcepub fn version_string(&self) -> Option<String>
pub fn version_string(&self) -> Option<String>
Get the version string without operators (for Cargo.toml format) Returns just “1.0.0” instead of “==1.0.0”
Sourcepub fn to_cargo_string(&self) -> Option<String>
pub fn to_cargo_string(&self) -> Option<String>
Serialize to Cargo.toml requirement syntax.
Cargo conventions: bare version = caret, = for exact pin, ~ for tilde, etc.
Sourcepub fn is_rewritable(&self) -> bool
pub fn is_rewritable(&self) -> bool
Returns true if this spec can be safely rewritten by an updater
Sourcepub fn with_version(&self, new_version: &Version) -> VersionSpec
pub fn with_version(&self, new_version: &Version) -> VersionSpec
Create a new version spec with updated version but same constraint type
Trait Implementations§
Source§impl Clone for VersionSpec
impl Clone for VersionSpec
Source§fn clone(&self) -> VersionSpec
fn clone(&self) -> VersionSpec
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more