[][src]Struct versions::Mess

pub struct Mess {
    pub chunks: Vec<MChunk>,
    pub next: Option<(Sep, Box<Mess>)>,
}

A complex version number with no specific structure.

Like Version this is a descriptive scheme, but it is based on examples of stupidly crafted, near-lawless version numbers used in the wild. Versions like this are a considerable burden to package management software.

With Mess, groups of letters/numbers are separated by a period, but can be further separated by the symbols _-+:.

Unfortunately, Chunks cannot be used here, as some developers have numbers like 1.003.04 which make parsers quite sad.

Some Mess values have a shape that is tantalizingly close to a SemVer. Example: 1.6.0a+2014+m872b87e73dfb-1. For values like these, we can extract the SemVer-compatible values out with nth.

In general this is not guaranteed to have well-defined ordering behaviour, but existing tests show sufficient consistency. nth is used internally where appropriate to enhance accuracy.

Examples

use versions::{Mess, SemVer, Version};

let mess = "20.0026.1_0-2+0.93";

let s = SemVer::new(mess);
let v = Version::new(mess);
let m = Mess::new(mess);

assert!(s.is_none());
assert!(v.is_none());
assert_eq!(Some(mess.to_string()), m.map(|v| format!("{}", v)));

Fields

chunks: Vec<MChunk>next: Option<(Sep, Box<Mess>)>

Implementations

impl Mess[src]

pub fn new(s: &str) -> Option<Mess>[src]

Parse a Mess from some input.

pub fn nth(&self, x: usize) -> Option<u32>[src]

Try to extract a position from the Mess as a nice integer, as if it were a SemVer.

use versions::Mess;

let mess = Mess::new("1.6a.0+2014+m872b87e73dfb-1").unwrap();
assert_eq!(Some(1), mess.nth(0));
assert_eq!(None, mess.nth(1));
assert_eq!(Some(0), mess.nth(2));

Trait Implementations

impl Clone for Mess[src]

impl Debug for Mess[src]

impl Display for Mess[src]

impl Eq for Mess[src]

impl Hash for Mess[src]

impl Ord for Mess[src]

Build metadata does not affect version precendence, and pre-release versions have lower precedence than normal versions.

impl PartialEq<Mess> for Mess[src]

impl PartialOrd<Mess> for Mess[src]

impl StructuralEq for Mess[src]

impl StructuralPartialEq for Mess[src]

Auto Trait Implementations

impl RefUnwindSafe for Mess

impl Send for Mess

impl Sync for Mess

impl Unpin for Mess

impl UnwindSafe for Mess

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.