[−][src]Struct versions::Version
A version number with decent structure and comparison logic.
This is a descriptive scheme, meaning that it encapsulates the most
common, unconscious patterns that developers use when assigning version
numbers to their software. If not SemVer, most
version numbers found in the wild will parse as a Version. These generally
conform to the x.x.x-x pattern, and may optionally have an epoch.
Epochs
Epochs are prefixes marked by a colon, like in 1:2.3.4. When comparing two
Version values, epochs take precedent. So 2:1.0.0 > 1:9.9.9. If one of
the given Versions has no epoch, its epoch is assumed to be 0.
Examples
use versions::{SemVer, Version}; // None of these are SemVer, but can still be parsed and compared. let vers = vec!["0.25-2", "8.u51-1", "20150826-1", "1:2.3.4"]; for v in vers { assert!(SemVer::new(v).is_none()); assert!(Version::new(v).is_some()); }
Fields
epoch: Option<u32>chunks: Chunksmeta: Option<Chunks>release: Option<Chunks>Implementations
impl Version[src]
pub fn new(s: &str) -> Option<Version>[src]
Parse a Version from some input.
pub fn nth(&self, n: usize) -> Option<u32>[src]
Try to extract a position from the Version as a nice integer, as if it
were a SemVer.
use versions::Version; let mess = Version::new("1:2.a.4.5.6.7-r1").unwrap(); assert_eq!(Some(2), mess.nth(0)); assert_eq!(None, mess.nth(1)); assert_eq!(Some(4), mess.nth(2));
pub fn nth_lenient(&self, n: usize) -> Option<u32>[src]
Like nth, but pulls a number even if it was followed by letters.
pub fn to_mess(&self) -> Mess[src]
A lossless conversion from Version to Mess.
use versions::Version; let orig = "1:1.2.3-r1"; let mess = Version::new(orig).unwrap().to_mess(); assert_eq!(orig, format!("{}", mess));
Trait Implementations
impl Clone for Version[src]
impl Debug for Version[src]
impl Display for Version[src]
impl Eq for Version[src]
impl Hash for Version[src]
fn hash<__H: Hasher>(&self, state: &mut __H)[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
impl Ord for Version[src]
fn cmp(&self, other: &Self) -> Ordering[src]
If two epochs are equal, we need to compare their actual version numbers. Otherwise, the comparison of the epochs is the only thing that matters.
#[must_use]fn max(self, other: Self) -> Self1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self[src]
impl PartialEq<Version> for Version[src]
impl PartialOrd<Version> for Version[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool1.0.0[src]
impl StructuralEq for Version[src]
impl StructuralPartialEq for Version[src]
Auto Trait Implementations
impl RefUnwindSafe for Version
impl Send for Version
impl Sync for Version
impl Unpin for Version
impl UnwindSafe for Version
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T> ToString for T where
T: Display + ?Sized, [src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,