Struct rustversion_detect::version::RustVersion
source · pub struct RustVersion {
pub major: u32,
pub minor: u32,
pub patch: u32,
pub channel: Channel,
}
Expand description
Indicates the rust version.
Fields§
§major: u32
The major version.
Should always be one.
minor: u32
The minor version of rust.
patch: u32
The patch version of the rust compiler.
channel: Channel
The channel of the rust compiler.
Implementations§
source§impl RustVersion
impl RustVersion
sourcepub const CURRENT: Self = crate::RUST_VERSION
pub const CURRENT: Self = crate::RUST_VERSION
The current rust version.
This is an alias for rustversion_detect::RUST_VERSION
.
sourcepub const fn stable(major: u32, minor: u32, patch: u32) -> RustVersion
pub const fn stable(major: u32, minor: u32, patch: u32) -> RustVersion
Create a stable version with the specified combination of major, minor, and patch.
The major version must be 1.0.
sourcepub const fn is_since(&self, spec: StableVersionSpec) -> bool
pub const fn is_since(&self, spec: StableVersionSpec) -> bool
Check if this version is after the specified stable version,
Ignores the channel.
The negation of Self::is_before
.
Behavior is (mostly) equivalent to #[rustversion::since($spec)]
§Example
assert!(RustVersion::stable(1, 32, 2).is_since(StableVersionSpec::minor(1, 32)));
assert!(RustVersion::stable(1, 48, 0).is_since(StableVersionSpec::patch(1, 32, 7)))
sourcepub const fn is_before(&self, spec: StableVersionSpec) -> bool
pub const fn is_before(&self, spec: StableVersionSpec) -> bool
Check if the version is greater than or equal to the specified version specification.
Ignores the channel.
The negation of Self::is_since
.
Behavior is (mostly) equivalent to #[rustversion::before($spec)]
sourcepub const fn is_since_nightly(&self, start: Date) -> bool
pub const fn is_since_nightly(&self, start: Date) -> bool
If this version is a nightly version after the specified start date.
Stable and beta versions are always considered before every nightly versions. Development versions are considered after every nightly version.
The negation of Self::is_before_nightly
.
Behavior is (mostly) equivalent to #[rustversion::since($date)]
See also Date::is_since
.
sourcepub const fn is_before_nightly(&self, start: Date) -> bool
pub const fn is_before_nightly(&self, start: Date) -> bool
If this version comes before the nightly version with the specified start date.
Stable and beta versions are always considered before every nightly versions. Development versions are considered after every nightly version.
The negation of Self::is_since_nightly
.
See also Date::is_before
.
sourcepub const fn is_nightly(&self) -> bool
pub const fn is_nightly(&self) -> bool
Check if a nightly compiler version is used.
sourcepub const fn is_development(&self) -> bool
pub const fn is_development(&self) -> bool
Check if a development compiler version is used
Trait Implementations§
source§impl Clone for RustVersion
impl Clone for RustVersion
source§fn clone(&self) -> RustVersion
fn clone(&self) -> RustVersion
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for RustVersion
impl Debug for RustVersion
source§impl Display for RustVersion
impl Display for RustVersion
Displays the version in a manner similar to rustc --version
.
The format here is not stable and may change in the future.
source§impl From<StableVersionSpec> for RustVersion
impl From<StableVersionSpec> for RustVersion
source§fn from(value: StableVersionSpec) -> Self
fn from(value: StableVersionSpec) -> Self
source§impl PartialEq for RustVersion
impl PartialEq for RustVersion
source§fn eq(&self, other: &RustVersion) -> bool
fn eq(&self, other: &RustVersion) -> bool
self
and other
values to be equal, and is used
by ==
.