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

Replace Zeroizing derive(Debug) with an empty block #825

Open
kayabaNerve opened this issue Dec 30, 2022 · 3 comments
Open

Replace Zeroizing derive(Debug) with an empty block #825

kayabaNerve opened this issue Dec 30, 2022 · 3 comments

Comments

@kayabaNerve
Copy link

I do understand this is opinionated, yet if I want the memory cleared when I'm done with it, I don't want to hear it's still in a log file somewhere. In my opinion, at least by default, Zeroizing should stub Debug with:

use core::fmt::{Debug, Formatter};
impl<Z> Debug for Zeroizing<Z> {
  fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), core::fmt::Error> {
    fmt.debug_struct("Zeroizing").finish()
  }
}
@tarcieri
Copy link
Member

Yeah, that would be OK, although it might be helpful to still display the inner type name via DebugStruct (as sourced via core::any::type_name) + finish_non_exhaustive

@kayabaNerve
Copy link
Author

Thanks for the tip on type_name. I learned of finish_non_exhaustive after this, yet can make a PR with this later 👍

@newpavlov
Copy link
Member

I don't think it's an area of responsibility for zeroize. Arguably, you should use the opaque-debug crate or add a manual opaque Debug implementation for your type which gets wrapped by Zeroizing.

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

No branches or pull requests

3 participants