utils icon indicating copy to clipboard operation
utils copied to clipboard

Replace Zeroizing derive(Debug) with an empty block

Open kayabaNerve opened this issue 3 years ago • 3 comments

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()
  }
}

kayabaNerve avatar Dec 30 '22 08:12 kayabaNerve

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

tarcieri avatar Dec 30 '22 15:12 tarcieri

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

kayabaNerve avatar Dec 31 '22 18:12 kayabaNerve

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.

newpavlov avatar Mar 01 '24 12:03 newpavlov