pub struct RustVersion {
pub major: u16,
pub minor: u16,
pub patch: u16,
}
Fields§
§major: u16
The MAJOR number in SemVer snytax (e.g. MAJOR.MINOR.PATCH).
minor: u16
The MINOR number in SemVer snytax (e.g. MAJOR.MINOR.PATCH).
patch: u16
The PATCH number in SemVer snytax (e.g. MAJOR.MINOR.PATCH).
Implementations§
Source§impl RustVersion
impl RustVersion
pub fn new<V: ToVersion>(version: V) -> Self
Sourcepub fn to_timestamp(&self) -> Result<i64>
pub fn to_timestamp(&self) -> Result<i64>
Returns the associated timestamp with the version. This is done by getting what commit.
Sourcepub fn to_commit_id(&self) -> Result<&'static str>
pub fn to_commit_id(&self) -> Result<&'static str>
Returns the commit id for the Rust Version, if it exists. Returns an error if it doesn’t exist (likely because the version doesn’t exist, or these isn’t a commit tagged as the release; unlikely).
Sourcepub fn exists_in_stable(&self) -> bool
pub fn exists_in_stable(&self) -> bool
Returns true if the version has ever been been declared.
For example, the version 1.77.2 would return true
while the version
1.77.9 would return false
, because there never was a version 1.77.9.
Note that the nightly or beta version would output false
, as it’s not in stable yet.
assert_eq!(RustVersion::new("1.77.2").exists_in_stable(), true);
assert_eq!(RustVersion::new("1.101.9000").exists_in_stable(), false)
Sourcepub fn timestamp_to_version(timestamp: i64) -> Result<Self>
pub fn timestamp_to_version(timestamp: i64) -> Result<Self>
Converts a timestamp to a version. This method can return a
RustVersion
up to two MINOR versions highers than the current
stable one to account for beta and nightly versions.