Enum versions::Versioning
source · pub enum Versioning {
Ideal(SemVer),
General(Version),
Complex(Mess),
}
Expand description
A top-level Versioning type which acts as a wrapper for the more specific types.
Examples
use versions::Versioning;
let a = Versioning::new("1.2.3-1").unwrap(); // SemVer.
let b = Versioning::new("1.2.3r1").unwrap(); // Not SemVer but good enough.
let c = Versioning::new("000.007-1").unwrap(); // Garbage.
assert!(a.is_ideal());
assert!(b.is_general());
assert!(c.is_complex());
Variants§
Ideal(SemVer)
Follows good parsing and comparison rules.
General(Version)
A little more permissive than SemVer
.
Complex(Mess)
Hope that you need not venture here.
Implementations§
source§impl Versioning
impl Versioning
sourcepub fn new(s: &str) -> Option<Versioning>
pub fn new(s: &str) -> Option<Versioning>
sourcepub fn parse(i: &str) -> IResult<&str, Versioning>
pub fn parse(i: &str) -> IResult<&str, Versioning>
The raw nom
parser for Versioning
. Feel free to use this in
combination with other general nom
parsers.
sourcepub fn is_general(&self) -> bool
pub fn is_general(&self) -> bool
A short-hand for detecting an inner Version
.
sourcepub fn is_complex(&self) -> bool
pub fn is_complex(&self) -> bool
A short-hand for detecting an inner Mess
.
sourcepub fn nth(&self, n: usize) -> Option<u32>
pub fn nth(&self, n: usize) -> Option<u32>
Try to extract a position from the Versioning
as a nice integer, as if it
were a SemVer
.
use versions::Versioning;
let semver = Versioning::new("1.2.3-r1+git123").unwrap();
assert!(semver.is_ideal());
assert_eq!(Some(1), semver.nth(0));
assert_eq!(Some(2), semver.nth(1));
assert_eq!(Some(3), semver.nth(2));
let version = Versioning::new("1:2.a.4.5.6.7-r1").unwrap();
assert!(version.is_general());
assert_eq!(Some(2), version.nth(0));
assert_eq!(None, version.nth(1));
assert_eq!(Some(4), version.nth(2));
let mess = Versioning::new("1.6a.0+2014+m872b87e73dfb-1").unwrap();
assert!(mess.is_complex());
assert_eq!(Some(1), mess.nth(0));
assert_eq!(None, mess.nth(1));
assert_eq!(Some(0), mess.nth(2));
Trait Implementations§
source§impl Clone for Versioning
impl Clone for Versioning
source§fn clone(&self) -> Versioning
fn clone(&self) -> Versioning
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for Versioning
impl Debug for Versioning
source§impl Default for Versioning
impl Default for Versioning
source§impl Display for Versioning
impl Display for Versioning
source§impl FromStr for Versioning
impl FromStr for Versioning
source§impl Hash for Versioning
impl Hash for Versioning
source§impl Ord for Versioning
impl Ord for Versioning
source§impl PartialEq for Versioning
impl PartialEq for Versioning
source§fn eq(&self, other: &Versioning) -> bool
fn eq(&self, other: &Versioning) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for Versioning
impl PartialOrd for Versioning
1.0.0 · source§fn 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 moresource§impl TryFrom<&str> for Versioning
impl TryFrom<&str> for Versioning
impl Eq for Versioning
impl StructuralEq for Versioning
impl StructuralPartialEq for Versioning
Auto Trait Implementations§
impl RefUnwindSafe for Versioning
impl Send for Versioning
impl Sync for Versioning
impl Unpin for Versioning
impl UnwindSafe for Versioning
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