Skip to content

Commit

Permalink
refactor: implement Display for Status instead of ToString
Browse files Browse the repository at this point in the history
  • Loading branch information
MonterraByte committed Dec 3, 2024
1 parent 66c0aa1 commit 266101d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/cargo_ops/elaborate_workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,8 @@ impl<'ela> ElaborateWorkspace<'ela> {
"{}\t{}\t{}\t{}\t{:?}\t{}\n",
label,
pkg.version(),
status.compat.to_string(),
status.latest.to_string(),
status.compat,
status.latest,
dependency.kind(),
dependency
.platform()
Expand All @@ -331,8 +331,8 @@ impl<'ela> ElaborateWorkspace<'ela> {
"{}\t{}\t{}\t{}\t---\t---\n",
name,
pkg.version(),
status.compat.to_string(),
status.latest.to_string()
status.compat,
status.latest
);
lines.insert(line);
}
Expand Down
14 changes: 8 additions & 6 deletions src/cargo_ops/pkg_status.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::fmt;

use semver::Version;

/// Enum which represents the update status of a package
Expand All @@ -24,12 +26,12 @@ impl Status {
pub fn is_changed(&self) -> bool { !matches!(*self, Status::Unchanged) }
}

impl ::std::string::ToString for Status {
fn to_string(&self) -> String {
match *self {
Status::Unchanged => "---".to_owned(),
Status::Removed => "Removed".to_owned(),
Status::Version(ref v) => v.to_string(),
impl fmt::Display for Status {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Status::Unchanged => write!(f, "---"),
Status::Removed => write!(f, "Removed"),
Status::Version(version) => version.fmt(f),
}
}
}
Expand Down

0 comments on commit 266101d

Please sign in to comment.