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
- 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
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§
source§impl SemVer
impl SemVer
sourcepub fn to_version(&self) -> Version
pub fn to_version(&self) -> Version
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));
Trait Implementations§
source§impl Hash for SemVer
impl Hash for SemVer
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.
source§impl Ord for SemVer
impl Ord for SemVer
Build metadata does not affect version precendence, and pre-release versions have lower precedence than normal versions.
source§impl PartialEq<SemVer> for SemVer
impl PartialEq<SemVer> for SemVer
Two SemVers are equal if all fields except metadata are equal.
source§impl PartialOrd<SemVer> for SemVer
impl PartialOrd<SemVer> for SemVer
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more