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
sourceimpl 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
sourceimpl 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.
sourceimpl Ord for SemVer
impl Ord for SemVer
Build metadata does not affect version precendence, and pre-release versions have lower precedence than normal versions.
1.21.0 · sourcefn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialEq<SemVer> for SemVer
impl PartialEq<SemVer> for SemVer
Two SemVers are equal if all fields except metadata are equal.
sourceimpl PartialOrd<SemVer> for SemVer
impl PartialOrd<SemVer> for SemVer
sourcefn partial_cmp(&self, other: &SemVer) -> Option<Ordering>
fn partial_cmp(&self, other: &SemVer) -> Option<Ordering>
1.0.0 · sourcefn 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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more