pub struct Semver {
pub major: u64,
pub minor: u64,
pub patch: u64,
}Expand description
A semantic version: major, minor and patch. A pre-release or build
part after - or + is not part of the order.
use riff_core::build::Semver;
let v: Semver = "0.4.1".parse().unwrap();
assert_eq!(v, Semver { major: 0, minor: 4, patch: 1 });
assert_eq!(v.line(), "0.4");
assert_eq!("1.2.0-rc1".parse::<Semver>().unwrap().line(), "1");
assert!("0.4".parse::<Semver>().is_err());
assert!("v0.4.1".parse::<Semver>().is_err());Fields§
§major: u64§minor: u64§patch: u64Implementations§
Source§impl Semver
impl Semver
Sourcepub fn line_before(self) -> Option<Semver>
pub fn line_before(self) -> Option<Semver>
The first version of the line before this one. None for the
line 0.0, and for the first major: the last minor line of the
major 0 is not known.
use riff_core::build::Semver;
let v = |s: &str| s.parse::<Semver>().unwrap();
assert_eq!(v("0.4.2").line_before(), Some(v("0.3.0")));
assert_eq!(v("2.1.0").line_before(), Some(v("1.0.0")));
assert_eq!(v("1.0.0").line_before(), None);
assert_eq!(v("0.0.9").line_before(), None);Sourcepub fn line_after(self) -> Semver
pub fn line_after(self) -> Semver
The first version of the line after this one.
use riff_core::build::Semver;
let v = |s: &str| s.parse::<Semver>().unwrap();
assert_eq!(v("0.4.2").line_after(), v("0.5.0"));
assert_eq!(v("1.3.2").line_after(), v("2.0.0"));Sourcepub fn same_line(self, other: Semver) -> bool
pub fn same_line(self, other: Semver) -> bool
True when the two versions are on the same line.
use riff_core::build::Semver;
let v = |s: &str| s.parse::<Semver>().unwrap();
assert!(v("0.4.0").same_line(v("0.4.3")));
assert!(!v("0.4.0").same_line(v("0.5.0")));
assert!(v("1.2.0").same_line(v("1.9.4")));Sourcepub fn riff_lines(self) -> Vec<Semver>
pub fn riff_lines(self) -> Vec<Semver>
The lines of riff that a riff-server of this version talks
with, as the first version of each line: its own line
(01M3MX1DYY6AVDW946NR0B9T2C) and the line before
(01M3MX1E1EY1M7JGNCN6FCEVQK).
use riff_core::build::Semver;
let v = |s: &str| s.parse::<Semver>().unwrap();
assert_eq!(v("0.4.2").riff_lines(), [v("0.4.0"), v("0.3.0")]);
assert_eq!(v("1.3.0").riff_lines(), [v("1.0.0")]);
assert_eq!(v("4.1.0").riff_lines(), [v("4.0.0"), v("3.0.0")]);Trait Implementations§
Source§impl Ord for Semver
impl Ord for Semver
Source§impl PartialOrd for Semver
impl PartialOrd for Semver
impl Copy for Semver
impl Eq for Semver
impl StructuralPartialEq 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 UnsafeUnpin 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,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.