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: u32The major version.
minor: u32The minor version.
patch: u32The 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 for SemVer
impl PartialEq for SemVer
Two SemVers are equal if all fields except metadata are equal.
source§impl PartialOrd for SemVer
impl PartialOrd 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 moreimpl Eq for SemVer
impl StructuralEq for SemVer
Auto Trait Implementations§
impl RefUnwindSafe for SemVer
impl Send for SemVer
impl Sync for SemVer
impl Unpin for SemVer
impl UnwindSafe for SemVer
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more