pub struct Mess {
pub chunks: Vec<MChunk>,
pub next: Option<(Sep, Box<Mess>)>,
}
Expand description
A complex version number with no specific structure.
Like crate::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, Chunk
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
crate::SemVer
. Example: 1.6.0a+2014+m872b87e73dfb-1
. For values like
these, we can extract the SemVer-compatible values out with Mess::nth
.
In general this is not guaranteed to have well-defined ordering behaviour,
but existing tests show sufficient consistency. Mess::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>
The first section of a Mess
.
next: Option<(Sep, Box<Mess>)>
The rest of the Mess
.
Implementations§
source§impl Mess
impl Mess
sourcepub fn nth(&self, x: usize) -> Option<u32>
pub fn nth(&self, x: usize) -> Option<u32>
Try to extract a position from the Mess
as a nice integer, as if it
were a crate::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));
let mess = Mess::new("0:1.6a.0+2014+m872b87e73dfb-1").unwrap();
assert_eq!(Some(1), mess.nth(0));
Trait Implementations§
source§impl Ord for Mess
impl Ord for Mess
Build metadata does not affect version precendence, and pre-release versions have lower precedence than normal versions.
source§impl PartialOrd for Mess
impl PartialOrd for Mess
impl Eq for Mess
impl StructuralPartialEq for Mess
Auto Trait Implementations§
impl Freeze for Mess
impl RefUnwindSafe for Mess
impl Send for Mess
impl Sync for Mess
impl Unpin for Mess
impl UnwindSafe for Mess
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more