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
- Pre-release versions have lower precedence than normal versions.
- Build metadata does not affect version precedence.
- 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
minor: u32
patch: u32
pre_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
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));
Trait Implementations
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.
Build metadata does not affect version precendence, and pre-release versions have lower precedence than normal versions.
Two SemVers are equal if all fields except metadata are equal.
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
Auto Trait Implementations
impl RefUnwindSafe for SemVer
impl UnwindSafe for SemVer
Blanket Implementations
Mutably borrows from an owned value. Read more