[][src]Struct version_check::Version

pub struct Version(_);

Version number: major.minor.patch, ignoring release channel.

Methods

impl Version[src]

pub fn read() -> Option<Version>[src]

Reads the version of the running compiler. If it cannot be determined (see the top-level documentation), returns None.

Example

use version_check::Version;

match Version::read() {
    Some(d) => format!("Version is: {}", d),
    None => format!("Failed to read the version.")
};

pub fn parse(version: &str) -> Option<Version>[src]

Parse a Rust release version (of the form major[.minor[.patch[-channel]]]), ignoring the release channel, if any. Returns None if version is not a valid Rust version string.

Example

use version_check::Version;

let version = Version::parse("1.18.0").unwrap();
assert!(version.exactly("1.18.0"));

let version = Version::parse("1.20.0-nightly").unwrap();
assert!(version.exactly("1.20.0"));
assert!(version.exactly("1.20.0-beta"));

let version = Version::parse("1.3").unwrap();
assert!(version.exactly("1.3.0"));

let version = Version::parse("1").unwrap();
assert!(version.exactly("1.0.0"));

assert!(Version::parse("one.two.three").is_none());

pub fn at_least(&self, version: &str) -> bool[src]

Returns true if self is greater than or equal to version.

If version is greater than self, or if version is not a valid Rust version string, returns false.

Example

use version_check::Version;

let version = Version::parse("1.35.0").unwrap();

assert!(version.at_least("1.33.0"));
assert!(version.at_least("1.35.0"));
assert!(version.at_least("1.13.2"));

assert!(!version.at_least("1.35.1"));
assert!(!version.at_least("1.55.0"));

pub fn at_most(&self, version: &str) -> bool[src]

Returns true if self is less than or equal to version.

If version is less than self, or if version is not a valid Rust version string, returns false.

Example

use version_check::Version;

let version = Version::parse("1.35.0").unwrap();

assert!(version.at_most("1.35.1"));
assert!(version.at_most("1.55.0"));
assert!(version.at_most("1.35.0"));

assert!(!version.at_most("1.33.0"));
assert!(!version.at_most("1.13.2"));

pub fn exactly(&self, version: &str) -> bool[src]

Returns true if self is exactly equal to version.

If version is not equal to self, or if version is not a valid Rust version string, returns false.

Example

use version_check::Version;

let version = Version::parse("1.35.0").unwrap();

assert!(version.exactly("1.35.0"));

assert!(!version.exactly("1.33.0"));
assert!(!version.exactly("1.35.1"));
assert!(!version.exactly("1.13.2"));

Trait Implementations

impl PartialEq<Version> for Version[src]

impl Clone for Version[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Ord for Version[src]

fn max(self, other: Self) -> Self1.21.0[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self1.21.0[src]

Compares and returns the minimum of two values. Read more

fn clamp(self, min: Self, max: Self) -> Self[src]

🔬 This is a nightly-only experimental API. (clamp)

Restrict a value to a certain interval. Read more

impl Eq for Version[src]

impl Copy for Version[src]

impl PartialOrd<Version> for Version[src]

impl Debug for Version[src]

impl Display for Version[src]

Auto Trait Implementations

impl Send for Version

impl Sync for Version

Blanket Implementations

impl<T> From<T> for 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> Into<U> for T where
    U: From<T>, 
[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.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]