Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/rust-toolchain/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rust-toolchain"
version = "1.0.0"
version = "1.1.0"
authors = ["Martijn Gribnau <garm@ilumeo.com>"]
edition = "2021"
rust-version = "1.61"
Expand Down
15 changes: 15 additions & 0 deletions crates/rust-toolchain/src/version.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::fmt;
use std::fmt::Formatter;
use std::str::FromStr;

/// A three component, `major.minor.patch` version number.
Expand Down Expand Up @@ -68,6 +70,12 @@ impl FromStr for RustVersion {
}
}

impl fmt::Display for RustVersion {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.version)
}
}

#[derive(Clone, Debug, Eq, PartialEq, thiserror::Error)]
pub enum ParseError {
#[error("Expected '{0}' but got '{got}'", got = .1.map(|c| c.to_string()).unwrap_or_default())]
Expand All @@ -94,6 +102,13 @@ mod tests {
assert_eq!(version.patch(), 3);
}

#[test]
fn display() {
let version = RustVersion::new(12, 2, 24);

assert_eq!(&format!("{version}"), "12.2.24");
}

#[test]
fn partial_eq() {
let left = RustVersion::new(1, 2, 3);
Expand Down
Loading