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
For Rust, it is a Law that the following must hold:
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
Build metadata does not affect version precendence, and pre-release versions
have lower precedence than normal versions.
impl Ord for SemVer
Build metadata does not affect version precendence, and pre-release versions have lower precedence than normal versions.
Source§impl PartialOrd for SemVer
impl PartialOrd for SemVer
impl Eq for SemVer
Auto Trait Implementations§
impl Freeze for SemVer
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more