[][src]Struct versions::Chunk

pub struct Chunk(pub Vec<Unit>);

A logical unit of a version number.

Can consist of multiple letters and numbers. Groups of these (i.e. Chunks) are separated by periods to form a full version number.

Defined as a newtype wrapper so that we can define custom parser and trait methods.

Examples

  • r3
  • 0rc1
  • 20150826

Implementations

impl Chunk[src]

pub fn single_digit(&self) -> Option<u32>[src]

If this Chunk is made up of a single Unit::Digits, then pull out the inner value.

use versions::{Chunk, Unit};

let v = Chunk(vec![Unit::Digits(1)]);
assert_eq!(Some(1), v.single_digit());

let v = Chunk(vec![Unit::Letters("abc".to_string())]);
assert_eq!(None, v.single_digit());

let v = Chunk(vec![Unit::Digits(1), Unit::Letters("abc".to_string())]);
assert_eq!(None, v.single_digit());

pub fn single_digit_lenient(&self) -> Option<u32>[src]

Like single_digit, but will grab the u32 even if there were more values in the Chunk.

use versions::{Chunk, Unit};

let v = Chunk(vec![Unit::Digits(1)]);
assert_eq!(Some(1), v.single_digit_lenient());

let v = Chunk(vec![Unit::Letters("abc".to_string())]);
assert_eq!(None, v.single_digit_lenient());

let v = Chunk(vec![Unit::Digits(0), Unit::Letters("a".to_string())]);
assert_eq!(Some(0), v.single_digit_lenient());

Trait Implementations

impl Clone for Chunk[src]

impl Debug for Chunk[src]

impl Display for Chunk[src]

impl Eq for Chunk[src]

impl Hash for Chunk[src]

impl Ord for Chunk[src]

A custom implementation.

impl PartialEq<Chunk> for Chunk[src]

impl PartialOrd<Chunk> for Chunk[src]

impl StructuralEq for Chunk[src]

impl StructuralPartialEq for Chunk[src]

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

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.