Struct dia_semver::Range[][src]

pub struct Range { /* fields omitted */ }
👎 Deprecated:

Beta

Range

A range can be respresented in string, following these rules:

  • Start and end are placed inside one of [], [)…, separated by a comma.
  • [ and ] are inclusive.
  • ( and ) are exclusive.
  • White spaces can be included. They will be ignored by parser.
  • Length of the string must be equal to or smaller than 4096 bytes. It’s for protection against flood attack.

Notes

Large ranges, such as [,], (,), [start,], [,end]… are not supported. Technically it’s doable, but using such wild ranges in software development is not recommended.

Examples

use core::str::FromStr;
use dia_semver::{Range, Semver};

// An empty range
let range = Range::from(Semver::new(0, 1, 2)..Semver::new(0, 0, 0));
assert!(range.is_empty());

// Only one single semver
let range = Range::from(Semver::new(0, 1, 2));
assert!(range.contains(&Semver::new(0, 1, 2)));
assert!(range.contains(&Semver::new(0, 1, 3)) == false);

// Inclusive range
let range = Range::from_str("[0.1.2, 0.2.0-beta]")?;
assert!(range.contains(&Semver::new(0, 1, 3)));
assert!(range.contains(&Semver::from_str("0.2.0-alpha")?));
assert!(range.contains(&Semver::new(0, 2, 0)) == false);

// Exclusive range
let range = Range::from(Semver::new(0, 1, 2)..Semver::new(0, 2, 0));
assert!(range.contains(&Semver::new(0, 2, 0)) == false);

Implementations

impl Range[src]

pub fn start(&self) -> &Semver[src]

👎 Deprecated:

Beta

pub fn end(&self) -> &Semver[src]

👎 Deprecated:

Beta

pub fn is_empty(&self) -> bool[src]

👎 Deprecated:

Beta

pub fn contains(&self, semver: &Semver) -> bool[src]

👎 Deprecated:

Beta

Trait Implementations

impl Debug for Range[src]

impl Display for Range[src]

impl Eq for Range[src]

impl From<&'_ Semver> for Range[src]

impl From<Range<Semver>> for Range[src]

impl From<RangeInclusive<Semver>> for Range[src]

impl From<Semver> for Range[src]

impl FromStr for Range[src]

type Err = ParseSemverError

The associated error which can be returned from parsing.

impl Hash for Range[src]

impl PartialEq<Range> for Range[src]

impl StructuralEq for Range[src]

impl StructuralPartialEq for Range[src]

Auto Trait Implementations

impl RefUnwindSafe for Range

impl Send for Range

impl Sync for Range

impl Unpin for Range

impl UnwindSafe for Range

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> 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.