Struct versions::SemVer[][src]

pub struct SemVer {
    pub major: u32,
    pub minor: u32,
    pub patch: u32,
    pub pre_rel: Option<Chunks>,
    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: u32minor: u32patch: u32pre_rel: Option<Chunks>

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.

Note: Unlike SemVer, Version expects its metadata before the prerelease. For instance:

use versions::SemVer;

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

assert_eq!("1.2.3+git123-r1", 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

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

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

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

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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.