Struct cargo_deny::Version

source ·
pub struct Version {
    pub major: u64,
    pub minor: u64,
    pub patch: u64,
    pub pre: Prerelease,
    pub build: BuildMetadata,
}
Expand description

SemVer version as defined by https://semver.org.

Syntax

  • The major, minor, and patch numbers may be any integer 0 through u64::MAX. When representing a SemVer version as a string, each number is written as a base 10 integer. For example, 1.0.119.

  • Leading zeros are forbidden in those positions. For example 1.01.00 is invalid as a SemVer version.

  • The pre-release identifier, if present, must conform to the syntax documented for Prerelease.

  • The build metadata, if present, must conform to the syntax documented for BuildMetadata.

  • Whitespace is not allowed anywhere in the version.

Total ordering

Given any two SemVer versions, one is less than, greater than, or equal to the other. Versions may be compared against one another using Rust’s usual comparison operators.

  • The major, minor, and patch number are compared numerically from left to right, lexicographically ordered as a 3-tuple of integers. So for example version 1.5.0 is less than version 1.19.0, despite the fact that “1.19.0” < “1.5.0” as ASCIIbetically compared strings and 1.19 < 1.5 as real numbers.

  • When major, minor, and patch are equal, a pre-release version is considered less than the ordinary release: version 1.0.0-alpha.1 is less than version 1.0.0.

  • Two pre-releases of the same major, minor, patch are compared by lexicographic ordering of dot-separated components of the pre-release string.

    • Identifiers consisting of only digits are compared numerically: 1.0.0-pre.8 is less than 1.0.0-pre.12.

    • Identifiers that contain a letter or hyphen are compared in ASCII sort order: 1.0.0-pre12 is less than 1.0.0-pre8.

    • Any numeric identifier is always less than any non-numeric identifier: 1.0.0-pre.1 is less than 1.0.0-pre.x.

Example: 1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < 1.0.0-beta < 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0

Fields§

§major: u64§minor: u64§patch: u64§pre: Prerelease§build: BuildMetadata

Implementations§

Create Version with an empty pre-release and build metadata.

Equivalent to:

Version {
    major,
    minor,
    patch,
    pre: Prerelease::EMPTY,
    build: BuildMetadata::EMPTY,
}

Create Version by parsing from string representation.

Errors

Possible reasons for the parse to fail include:

  • 1.0 — too few numeric components. A SemVer version must have exactly three. If you are looking at something that has fewer than three numbers in it, it’s possible it is a VersionReq instead (with an implicit default ^ comparison operator).

  • 1.0.01 — a numeric component has a leading zero.

  • 1.0.unknown — unexpected character in one of the components.

  • 1.0.0- or 1.0.0+ — the pre-release or build metadata are indicated present but empty.

  • 1.0.0-alpha_123 — pre-release or build metadata have something outside the allowed characters, which are 0-9, A-Z, a-z, -, and . (dot).

  • 23456789999999999999.0.0 — overflow of a u64.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Deserialize this value from the given Serde deserializer. Read more
Formats the value using the given formatter. Read more
The associated error which can be returned from parsing.
Parses a string s to return a value of this type. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Converts self into T using Into<T>. Read more
Compare self to key and return true if they are equal.
Causes self to use its Binary implementation when Debug-formatted.
Causes self to use its Display implementation when Debug-formatted.
Causes self to use its LowerExp implementation when Debug-formatted.
Causes self to use its LowerHex implementation when Debug-formatted.
Causes self to use its Octal implementation when Debug-formatted.
Causes self to use its Pointer implementation when Debug-formatted.
Causes self to use its UpperExp implementation when Debug-formatted.
Causes self to use its UpperHex implementation when Debug-formatted.
Formats each item in a sequence. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Pipes by value. This is generally the method you want to use. Read more
Borrows self and passes that borrow into the pipe function. Read more
Mutably borrows self and passes that borrow into the pipe function. Read more
Borrows self, then passes self.borrow() into the pipe function. Read more
Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Borrows self, then passes self.as_ref() into the pipe function.
Mutably borrows self, then passes self.as_mut() into the pipe function.
Borrows self, then passes self.deref() into the pipe function.
Mutably borrows self, then passes self.deref_mut() into the pipe function.
The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Immutable access to a value. Read more
Mutable access to a value. Read more
Immutable access to the Borrow<B> of a value. Read more
Mutable access to the BorrowMut<B> of a value. Read more
Immutable access to the AsRef<R> view of a value. Read more
Mutable access to the AsMut<R> view of a value. Read more
Immutable access to the Deref::Target of a value. Read more
Mutable access to the Deref::Target of a value. Read more
Calls .tap() only in debug builds, and is erased in release builds.
Calls .tap_mut() only in debug builds, and is erased in release builds.
Calls .tap_borrow() only in debug builds, and is erased in release builds.
Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Calls .tap_ref() only in debug builds, and is erased in release builds.
Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Calls .tap_deref() only in debug builds, and is erased in release builds.
Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
Attempts to convert self into T using TryInto<T>. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.