Struct dia_semver::Range [−][src]
👎 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]
fn from(range: RangeInclusive<Semver>) -> Self
[src]
impl From<Semver> for Range
[src]
impl FromStr for Range
[src]
type Err = ParseSemverError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, Self::Err>
[src]
impl Hash for Range
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,