Skip to content

Commit

Permalink
Implement Display rather than ToString
Browse files Browse the repository at this point in the history
  • Loading branch information
jelmer committed Jul 17, 2024
1 parent 417c177 commit b2add94
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,16 @@ impl FromStr for Version {
}
}

impl ToString for Version {
fn to_string(&self) -> String {
let mut ret = vec![self.upstream_version.clone()];
impl std::fmt::Display for Version {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str(&self.upstream_version)?;
if let Some(epoch) = self.epoch.as_ref() {
ret.insert(0, format!("{}:", epoch));
write!(f, ":{}", epoch)?;
}
if let Some(debian_revision) = self.debian_revision.as_ref() {
ret.push(format!("-{}", debian_revision));
write!(f, "-{}", debian_revision)?;
}
ret.concat()
Ok(())
}
}

Expand Down

0 comments on commit b2add94

Please sign in to comment.