Struct dia_semver::Semver [] [src]

pub struct Semver {
    pub major: u64,
    pub minor: u64,
    pub patch: u64,
    pub pre_release: Option<String>,
    pub build_metadata: Option<String>,
}

Semver.

Some concepts

  • Strict parser does not allow leading/trailing while spaces; all 3 version numbers are required: major, minor, patch.
  • Tolerant parser ignores leading/trailing while spaces. Minor and patch version numbers are optional. This mode is added by the crate author, it's not described in official specification.

Usage

  • ::parse*() methods use strict parser. While ::new() and ::from_*() ones are more tolerant.

Full specification: https://semver.org

Fields

Methods

impl Semver
[src]

[src]

Parses input string to make a new semver.

Rules:

  • If strict is true, minor and patch version numbers are required. Leading/trailing while spaces are not allowed.
  • If strict is false, minor and patch version numbers are optional. Leading/trailing while spaces are ignored.

Examples

use dia_semver::Semver;

assert_eq!(Semver::parse("1.2.3", true).unwrap().to_string(), "1.2.3");
assert_eq!(Semver::parse("          1-a.b.c           ", false).unwrap().to_string(), "1.0.0-a.b.c");

[src]

Parses a &str.

This method calls ::parse() with false passed to strict.

[src]

Parses an &OsStr.

See ::parse() for details.

[src]

Parses an &OsStr.

This method calls ::parse_os_str() with false passed to strict.

[src]

Parses a &CStr.

See ::parse() for details.

[src]

Parses a &CStr.

This method calls ::parse_c_str() with false passed to strict.

Trait Implementations

impl Debug for Semver
[src]

[src]

Formats the value using the given formatter. Read more

impl Eq for Semver
[src]

impl PartialEq for Semver
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

1.0.0
[src]

This method tests for !=.

impl Ord for Semver
[src]

[src]

This method returns an Ordering between self and other. Read more

1.21.0
[src]

Compares and returns the maximum of two values. Read more

1.21.0
[src]

Compares and returns the minimum of two values. Read more

impl PartialOrd for Semver
[src]

[src]

This method returns an ordering between self and other values if one exists. Read more

1.0.0
[src]

This method tests less than (for self and other) and is used by the < operator. Read more

1.0.0
[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

1.0.0
[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

1.0.0
[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Hash for Semver
[src]

[src]

Feeds this value into the given [Hasher]. Read more

1.3.0
[src]

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

impl FromStr for Semver
[src]

The associated error which can be returned from parsing.

[src]

Parses a string s to return a value of this type. Read more

impl Display for Semver
[src]

[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl Send for Semver

impl Sync for Semver