Struct qt_build_utils::SemVer

source ·
pub struct SemVer {
    pub major: u32,
    pub minor: u32,
    pub patch: u32,
    pub pre_rel: Option<Release>,
    pub meta: Option<String>,
}
Expand description

An ideal version number that conforms to Semantic Versioning.

This is a prescriptive scheme, meaning that it follows the SemVer standard.

Legal semvers are of the form: MAJOR.MINOR.PATCH-PREREL+META

  • Simple Sample: 1.2.3
  • Full Sample: 1.2.3-alpha.2+a1b2c3.1

Extra Rules

  1. Pre-release versions have lower precedence than normal versions.
  2. Build metadata does not affect version precedence.
  3. PREREL and META strings may only contain ASCII alphanumerics.

Examples

use versions::SemVer;

let orig = "1.2.3-r1+git";
let attempt = SemVer::new(orig).unwrap();

assert_eq!(orig, format!("{}", attempt));

Fields

major: u32

The major version.

minor: u32

The minor version.

patch: u32

The patch version.

pre_rel: Option<Release>

Some implies that the inner Vec of the Chunks is not empty.

meta: Option<String>

Some implies that the inner String is not empty.

Implementations

Parse a SemVer from some input.

A lossless conversion from SemVer to Version.

use versions::SemVer;

let orig = "1.2.3-r1+git123";
let ver = SemVer::new(orig).unwrap().to_version();

assert_eq!("1.2.3-r1+git123", format!("{}", ver));

A lossless conversion from SemVer to Mess.

use versions::SemVer;

let orig = "1.2.3-r1+git123";
let mess = SemVer::new(orig).unwrap().to_mess();

assert_eq!(orig, format!("{}", mess));

The raw nom parser for SemVer. Feel free to use this in combination with other general nom parsers.

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
Returns the “default value” for a type. 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

For Rust, it is a Law that the following must hold:

k1 == k2 -> hash(k1) == hash(k2)

And so this is hand-implemented, since PartialEq also is.

Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more

Build metadata does not affect version precendence, and pre-release versions have lower precedence than normal versions.

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

Two SemVers are equal if all fields except metadata are equal.

This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
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
use versions::SemVer;

let orig = "1.2.3";
let prsd: SemVer = orig.try_into().unwrap();
assert_eq!(orig, prsd.to_string());
The type returned in the event of a conversion error.

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

Returns the argument unchanged.

Calls U::from(self).

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

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
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.