Struct version_check::Version[][src]

pub struct Version(_);
Expand description

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

Implementations

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.")
};

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());
assert!(Version::parse("1.65536.2").is_none());
assert!(Version::parse("1. 2").is_none());
assert!(Version::parse("").is_none());
assert!(Version::parse("1.").is_none());
assert!(Version::parse("1.2.3.4").is_none());

Creates a Version from (major, minor, patch) version components.

Example
use version_check::Version;

assert!(Version::from_mmp(1, 35, 0).exactly("1.35.0"));
assert!(Version::from_mmp(1, 33, 0).exactly("1.33.0"));
assert!(Version::from_mmp(1, 35, 1).exactly("1.35.1"));
assert!(Version::from_mmp(1, 13, 2).exactly("1.13.2"));

Returns the (major, minor, patch) version components of self.

Example
use version_check::Version;

assert_eq!(Version::parse("1.35.0").unwrap().to_mmp(), (1, 35, 0));
assert_eq!(Version::parse("1.33.0").unwrap().to_mmp(), (1, 33, 0));
assert_eq!(Version::parse("1.35.1").unwrap().to_mmp(), (1, 35, 1));
assert_eq!(Version::parse("1.13.2").unwrap().to_mmp(), (1, 13, 2));

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"));

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

assert!(version.at_least("1.12.0"));
assert!(!version.at_least("1.35.0"));

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"));

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

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

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.