pub struct Version {
pub major: usize,
pub minor: Option<usize>,
pub patch: Option<usize>,
pub pre: Option<VersionState>,
}Expand description
Semantic Version representation.
§Examples
Basic usage:
let v: Version = "1.2.3rc4".parse().unwrap();Fields§
§major: usize§minor: Option<usize>§patch: Option<usize>§pre: Option<VersionState>Implementations§
Source§impl Version
impl Version
Sourcepub fn is_stable(&self) -> bool
pub fn is_stable(&self) -> bool
Returns true if the version defines a stable
release (not suffixed with an alpha, beta or rc
version part).
§Example
let version: Version = "1.2".parse().unwrap();
assert!(version.is_stable());
let version: Version = "1.3rc1".parse().unwrap();
assert!(!version.is_stable());Sourcepub fn covers(&self, other: &Version) -> bool
pub fn covers(&self, other: &Version) -> bool
Returns true if the current version covers
the given other version.
§Example
let a: Version = "1.2".parse().unwrap();
let b: Version = "1.2".parse().unwrap();
assert!(a.covers(&b));
let a: Version = "1".parse().unwrap();
let b: Version = "1.2.1".parse().unwrap();
assert!(a.covers(&b));
let a: Version = "1.3".parse().unwrap();
let b: Version = "1.3.7".parse().unwrap();
assert!(a.covers(&b));
let a: Version = "1.2.3".parse().unwrap();
let b: Version = "1.2.3rc1".parse().unwrap();
assert!(a.covers(&b));
let a: Version = "1.3".parse().unwrap();
let b: Version = "1.2.1".parse().unwrap();
assert!(!a.covers(&b));Sourcepub fn strip_after(&self, part: VersionPart) -> Self
pub fn strip_after(&self, part: VersionPart) -> Self
Returns a copy of the Version with the part after the
given VersionPart removed.
§Example
let a: Version = "1.2.3rc1".parse().unwrap();
let b: Version = "1".parse().unwrap();
assert_eq!(a.strip_after(VersionPart::Major), b);
let a: Version = "1.2.3rc1".parse().unwrap();
let b: Version = "1.2".parse().unwrap();
assert_eq!(a.strip_after(VersionPart::Minor), b);
let a: Version = "1.2.3rc1".parse().unwrap();
let b: Version = "1.2.3".parse().unwrap();
assert_eq!(a.strip_after(VersionPart::Patch), b);Trait Implementations§
Source§impl Ord for Version
impl Ord for Version
Source§impl PartialOrd for Version
impl PartialOrd for Version
impl Eq for Version
impl StructuralPartialEq for Version
Auto Trait Implementations§
impl Freeze for Version
impl RefUnwindSafe for Version
impl Send for Version
impl Sync for Version
impl Unpin for Version
impl UnwindSafe for Version
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