Skip to main content

Version

Struct Version 

Source
pub struct Version<T: AsRef<str> = String> {
    pub version: T,
    pub flags: VersionFlags,
}
Expand description

Version string with flags.

A type which holds version string along with associated VersionFlags, allowing comparison and ordering.

assert!(Version::new("1.0") < Version::new("1.1"));
assert!(Version::new("1.1") == Version::new("1.0001"));

assert!(Version::new("1.0") < Version::new("1.1".to_string()));
assert!(Version::new("1.1") == Version::new("1.0001".to_string()));

assert!(Version::new("1.0".to_string()) < Version::new("1.1".to_string()));
assert!(Version::new("1.1".to_string()) == Version::new("1.0001".to_string()));

Fields§

§version: T

Version string.

§flags: VersionFlags

Associated flags to tweak version comparison.

Implementations§

Source§

impl<T: AsRef<str>> Version<T>

Source

pub fn new(version: T) -> Self

Create version from string.

Uses default (empty) flags.

Source

pub fn with_flags(version: T, flags: VersionFlags) -> Self

Create version from string and flags.

Trait Implementations§

Source§

impl<T: Debug + AsRef<str>> Debug for Version<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: AsRef<str>> Ord for Version<T>

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T, U> PartialEq<Version<U>> for Version<T>
where T: AsRef<str>, U: AsRef<str>,

Source§

fn eq(&self, other: &Version<U>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T, U> PartialOrd<Version<U>> for Version<T>
where T: AsRef<str>, U: AsRef<str>,

Source§

fn partial_cmp(&self, other: &Version<U>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T: AsRef<str>> Eq for Version<T>

Auto Trait Implementations§

§

impl<T> Freeze for Version<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Version<T>
where T: RefUnwindSafe,

§

impl<T> Send for Version<T>
where T: Send,

§

impl<T> Sync for Version<T>
where T: Sync,

§

impl<T> Unpin for Version<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Version<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for Version<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.