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
major: u64
minor: u64
patch: u64
pre_release: Option<String>
build_metadata: Option<String>
Methods
impl Semver
[src]
pub fn parse(s: &str, strict: bool) -> Result<Semver, ParseSemverError>
[src]
Parses input string to make a new semver.
Rules:
- If
strict
istrue
, minor and patch version numbers are required. Leading/trailing while spaces are not allowed. - If
strict
isfalse
, 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");
pub fn new(s: &str) -> Result<Semver, ParseSemverError>
[src]
pub fn parse_os_str(s: &OsStr, strict: bool) -> Result<Semver, ParseSemverError>
[src]
pub fn from_os_str(s: &OsStr) -> Result<Semver, ParseSemverError>
[src]
Parses an &OsStr
.
This method calls ::parse_os_str()
with false
passed to strict
.
pub fn parse_c_str(s: &CStr, strict: bool) -> Result<Semver, ParseSemverError>
[src]
pub fn from_c_str(s: &CStr) -> Result<Semver, ParseSemverError>
[src]
Parses a &CStr
.
This method calls ::parse_c_str()
with false
passed to strict
.
Trait Implementations
impl Debug for Semver
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Eq for Semver
[src]
impl PartialEq for Semver
[src]
fn eq(&self, other: &Semver) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl Ord for Semver
[src]
fn cmp(&self, other: &Semver) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
impl PartialOrd for Semver
[src]
fn partial_cmp(&self, other: &Semver) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
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]
fn hash<H: Hasher>(&self, state: &mut H)
[src]
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl FromStr for Semver
[src]
type Err = ParseSemverError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, Self::Err>
[src]
Parses a string s
to return a value of this type. Read more