Skip to content

Commit

Permalink
Implement Display for SignatureAlgorithm
Browse files Browse the repository at this point in the history
Clippy dropped an error because `SignatureAlgorithm` implemented trait
`ToString` directly, while the recommnded way is to use
`std::fmt::Display`. This commit updates the trait implementation.

Signed-off-by: Mark Kirichenko <[email protected]>
  • Loading branch information
atanzu committed Jan 12, 2025
1 parent a3970bd commit 60941d8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/crypto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,14 @@ impl FromStr for SignatureAlgorithm {
}
}

impl ToString for SignatureAlgorithm {
fn to_string(&self) -> String {
match self {
impl std::fmt::Display for SignatureAlgorithm {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let string_name = match self {
SignatureAlgorithm::ES256 => "ES256",
SignatureAlgorithm::ES384 => "ES384",
SignatureAlgorithm::ES512 => "ES512",
}
.to_string()
};
write!(f, "{}", string_name)
}
}

Expand Down

0 comments on commit 60941d8

Please sign in to comment.