pub enum Chunk {
Numeric(u32),
Alphanum(String),
}
Expand description
A logical unit of a version number.
Either entirely numerical (with no leading zeroes) or entirely alphanumerical (with a free mixture of numbers, letters, and hyphens).
Groups of these (like Release
) are separated by periods to form a full
section of a version number.
§Examples
1
20150826
r3
0rc1-abc3
Variants§
Implementations§
Source§impl Chunk
impl Chunk
Sourcepub fn single_digit(&self) -> Option<u32>
pub fn single_digit(&self) -> Option<u32>
If this Chunk
is made up of a single digit, then pull out the inner
value.
use versions::Chunk;
let v = Chunk::Numeric(1);
assert_eq!(Some(1), v.single_digit());
let v = Chunk::Alphanum("abc".to_string());
assert_eq!(None, v.single_digit());
let v = Chunk::Alphanum("1abc".to_string());
assert_eq!(None, v.single_digit());
Sourcepub fn single_digit_lenient(&self) -> Option<u32>
pub fn single_digit_lenient(&self) -> Option<u32>
Like Chunk::single_digit
, but will grab a leading u32
even if
followed by letters.
use versions::Chunk;
let v = Chunk::Numeric(1);
assert_eq!(Some(1), v.single_digit_lenient());
let v = Chunk::Alphanum("abc".to_string());
assert_eq!(None, v.single_digit_lenient());
let v = Chunk::Alphanum("1abc".to_string());
assert_eq!(Some(1), v.single_digit_lenient());
Sourcepub fn single_digit_lenient_post(&self) -> Option<u32>
pub fn single_digit_lenient_post(&self) -> Option<u32>
Like Chunk::single_digit
, but will grab a trailing u32
.
use versions::Chunk;
let v = Chunk::Alphanum("r23".to_string());
assert_eq!(Some(23), v.single_digit_lenient_post());
Trait Implementations§
impl Eq for Chunk
impl StructuralPartialEq for Chunk
Auto Trait Implementations§
impl Freeze for Chunk
impl RefUnwindSafe for Chunk
impl Send for Chunk
impl Sync for Chunk
impl Unpin for Chunk
impl UnwindSafe for Chunk
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,
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>
Converts
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>
Converts
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