version_check

Struct Channel

Source
pub struct Channel(/* private fields */);
Expand description

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

Implementations§

Source§

impl Channel

Source

pub fn read() -> Option<Channel>

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

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

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());
Source

pub fn supports_features(&self) -> bool

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

Please see the note on feature detection.

§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());
Source

pub fn is_dev(&self) -> bool

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());
Source

pub fn is_nightly(&self) -> bool

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());
Source

pub fn is_beta(&self) -> bool

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());
Source

pub fn is_stable(&self) -> bool

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§

Source§

impl Clone for Channel

Source§

fn clone(&self) -> Channel

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Channel

Source§

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

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

impl Display for Channel

Source§

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

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

impl PartialEq for Channel

Source§

fn eq(&self, other: &Channel) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 Copy for Channel

Source§

impl Eq for Channel

Source§

impl StructuralPartialEq for Channel

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.