[−][src]Struct version_check::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(&self) -> 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 cmp(&self, other: &Version) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
fn clamp(self, min: Self, max: Self) -> Self
[src]
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]
fn partial_cmp(&self, other: &Version) -> Option<Ordering>
[src]
fn lt(&self, other: &Version) -> bool
[src]
fn le(&self, other: &Version) -> bool
[src]
fn gt(&self, other: &Version) -> bool
[src]
fn ge(&self, other: &Version) -> bool
[src]
impl Debug for Version
[src]
impl Display for Version
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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.
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,