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
Numeric(u32)
A nice, pure number.
Alphanum(String)
A mixture of letters, numbers, and hyphens.
Implementations
sourceimpl 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
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more