pub struct Channel(/* private fields */);
Expand description
Release channel: “dev”, “nightly”, “beta”, or “stable”.
Implementations§
Source§impl Channel
impl Channel
Sourcepub fn read() -> Option<Channel>
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.")
};
Sourcepub fn parse(version: &str) -> Option<Channel>
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());
Sourcepub fn supports_features(&self) -> bool
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());
Sourcepub fn is_dev(&self) -> bool
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());
Sourcepub fn is_nightly(&self) -> bool
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());
Trait Implementations§
impl Copy for Channel
impl Eq for Channel
impl StructuralPartialEq for Channel
Auto Trait Implementations§
impl Freeze for Channel
impl RefUnwindSafe for Channel
impl Send for Channel
impl Sync for Channel
impl Unpin for Channel
impl UnwindSafe for Channel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more