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());
Trait Implementations§
source§impl PartialEq for Chunk
impl PartialEq for Chunk
impl Eq for Chunk
impl StructuralEq for Chunk
impl StructuralPartialEq for Chunk
Auto Trait Implementations§
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