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 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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)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