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 326a467
Showing 1 changed file with 8 additions and 6 deletions.
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 326a467

Please sign in to comment.