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 fn stable(major: u32, minor: u32, patch: u32) -> RustVersion
pub 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 fn is_since_minor_version(&self, major: u32, minor: u32) -> bool
pub fn is_since_minor_version(&self, major: u32, minor: u32) -> bool
Check if this version is after the specified stable minor version.
The patch version is unspecified and will be ignored.
This is a shorthand for calling Self::is_since_stable
with a minor version
spec created with StableVersionSpec::minor
.
The major version must always be one, or a panic could happen.
§Example
assert!(RustVersion::stable(1, 32, 2).is_since_minor_version(1, 32));
assert!(RustVersion::stable(1, 48, 0).is_since_minor_version(1, 40));
Sourcepub fn is_since_patch_version(&self, major: u32, minor: u32, patch: u32) -> bool
pub fn is_since_patch_version(&self, major: u32, minor: u32, patch: u32) -> bool
Check if this version is after the specified stable patch version.
This is a shorthand for calling Self::is_since_stable
with a patch version
spec created with StableVersionSpec::patch
.
The major version must always be one, or a panic could happen.
§Example
assert!(RustVersion::stable(1, 32, 2).is_since_patch_version(1, 32, 1));
assert!(RustVersion::stable(1, 48, 0).is_since_patch_version(1, 40, 5));
Sourcepub fn is_since_stable(&self, spec: StableVersionSpec) -> bool
pub fn is_since_stable(&self, spec: StableVersionSpec) -> bool
Check if this version is after the given stable version spec.
In general, the Self::is_since_minor_version
and Self::is_since_patch_version
helper methods are preferable.
This ignores the channel.
The negation of Self::is_before_stable
.
Behavior is (mostly) equivalent to #[rustversion::since($spec)]
§Example
assert!(RustVersion::stable(1, 32, 2).is_since_stable(StableVersionSpec::minor(1, 32)));
assert!(RustVersion::stable(1, 48, 0).is_since_stable(StableVersionSpec::patch(1, 32, 7)))
Sourcepub fn is_before_stable(&self, spec: StableVersionSpec) -> bool
pub fn is_before_stable(&self, spec: StableVersionSpec) -> bool
Check if the version is less than the given stable version spec.
This ignores the channel.
In general, the Self::is_before_minor_version
and Self::is_before_patch_version
helper methods are preferable.
The negation of Self::is_since_stable
.
Behavior is (mostly) equivalent to #[rustversion::before($spec)]
Sourcepub fn is_before_minor_version(&self, major: u32, minor: u32) -> bool
pub fn is_before_minor_version(&self, major: u32, minor: u32) -> bool
Check if this version is before the specified stable minor version.
The patch version is unspecified and will be ignored.
This is a shorthand for calling Self::is_before_stable
with a minor version
spec created with StableVersionSpec::minor
.
The major version must always be one, or a panic could happen.
Sourcepub fn is_before_patch_version(
&self,
major: u32,
minor: u32,
patch: u32,
) -> bool
pub fn is_before_patch_version( &self, major: u32, minor: u32, patch: u32, ) -> bool
Check if this version is before the specified stable patch version.
This is a shorthand for calling Self::is_before_stable
with a patch version
spec created with StableVersionSpec::patch
.
The major version must always be one, or a panic could happen.
Sourcepub fn is_since_nightly(&self, start: Date) -> bool
pub 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 fn is_before_nightly(&self, start: Date) -> bool
pub 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 fn is_nightly(&self) -> bool
pub fn is_nightly(&self) -> bool
Check if this is a nightly compiler version.
Sourcepub fn is_development(&self) -> bool
pub fn is_development(&self) -> bool
Check if this is a development compiler version.
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
Displays the version in a manner similar to rustc --version
.
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.