Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Clippy lints #1598

Merged
merged 2 commits into from
Jun 24, 2024
Merged

Fix Clippy lints #1598

merged 2 commits into from
Jun 24, 2024

Conversation

newpavlov
Copy link
Member

No description provided.

@@ -503,6 +503,7 @@ where
}

#[cfg(feature = "pem")]
#[allow(clippy::to_string_trait_impl)]
Copy link
Member Author

@newpavlov newpavlov Jun 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tarcieri
Maybe it's better remove ToString implementations? The trait docs state the following:

This trait is automatically implemented for any type which implements the Display trait. As such, ToString shouldn’t be implemented directly: Display should be implemented instead, and you get the ToString implementation for free.

But implementing Display on top of to_public_key_pem would look really wrong.

Copy link
Member

@tarcieri tarcieri Jun 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is currently no way to use core::fmt::Formatter to serialize PEM, so ToString is the only option here.

You could potentially open an issue to add such support, but pem-rfc7468 is designed around constant-time operation (not really important here due to it being a public key).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, why have this implementation in the first place? Users should prefer using the to_public_key_pem method since it explicitly states how serialization is performed. IIUC ToString intended for user-facing serialization and PEM serialization arguably barely fits here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will leave the implementation as is, but I think it may be worth to remove it in a separate PR.

@newpavlov newpavlov merged commit bdd58bd into master Jun 24, 2024
24 checks passed
@newpavlov newpavlov deleted the clippy_fix branch June 24, 2024 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants