Struct version_check::Channel[][src]

pub struct Channel(_);

Release channel: “dev”, “nightly”, “beta”, or “stable”.

Implementations

impl Channel[src]

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

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

Example

use version_check::Channel;

match Channel::read() {
    Some(c) => format!("The channel is: {}", c),
    None => format!("Failed to read the release channel.")
};

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

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

Example

use version_check::Channel;

let dev = Channel::parse("1.3.0-dev").unwrap();
assert!(dev.is_dev());

let nightly = Channel::parse("1.42.2-nightly").unwrap();
assert!(nightly.is_nightly());

let beta = Channel::parse("1.32.0-beta").unwrap();
assert!(beta.is_beta());

let stable = Channel::parse("1.4.0").unwrap();
assert!(stable.is_stable());

pub fn supports_features(&self) -> bool[src]

Returns true if this channel supports feature flags. In other words, returns true if the channel is either dev or nightly.

Example

use version_check::Channel;

let dev = Channel::parse("1.3.0-dev").unwrap();
assert!(dev.supports_features());

let nightly = Channel::parse("1.42.2-nightly").unwrap();
assert!(nightly.supports_features());

let beta = Channel::parse("1.32.0-beta").unwrap();
assert!(!beta.supports_features());

let stable = Channel::parse("1.4.0").unwrap();
assert!(!stable.supports_features());

pub fn is_dev(&self) -> bool[src]

Returns true if this channel is dev and false otherwise.

Example

use version_check::Channel;

let dev = Channel::parse("1.3.0-dev").unwrap();
assert!(dev.is_dev());

let stable = Channel::parse("1.0.0").unwrap();
assert!(!stable.is_dev());

pub fn is_nightly(&self) -> bool[src]

Returns true if this channel is nightly and false otherwise.

Example

use version_check::Channel;

let nightly = Channel::parse("1.3.0-nightly").unwrap();
assert!(nightly.is_nightly());

let stable = Channel::parse("1.0.0").unwrap();
assert!(!stable.is_nightly());

pub fn is_beta(&self) -> bool[src]

Returns true if this channel is beta and false otherwise.

Example

use version_check::Channel;

let beta = Channel::parse("1.3.0-beta").unwrap();
assert!(beta.is_beta());

let stable = Channel::parse("1.0.0").unwrap();
assert!(!stable.is_beta());

pub fn is_stable(&self) -> bool[src]

Returns true if this channel is stable and false otherwise.

Example

use version_check::Channel;

let stable = Channel::parse("1.0.0").unwrap();
assert!(stable.is_stable());

let beta = Channel::parse("1.3.0-beta").unwrap();
assert!(!beta.is_stable());

Trait Implementations

impl Clone for Channel[src]

impl Copy for Channel[src]

impl Debug for Channel[src]

impl Display for Channel[src]

impl Eq for Channel[src]

impl PartialEq<Channel> for Channel[src]

impl StructuralEq for Channel[src]

impl StructuralPartialEq for Channel[src]

Auto Trait Implementations

impl RefUnwindSafe for Channel

impl Send for Channel

impl Sync for Channel

impl Unpin for Channel

impl UnwindSafe for Channel

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

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