Skip to content

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

Closed

Description

@kayabaNerve

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

Activity

  1. tarcieri commented on Dec 30, 2022

    @tarcieri
    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

  2. kayabaNerve commented on Dec 31, 2022

    @kayabaNerve
    ContributorAuthor

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

  3. newpavlov commented on Mar 1, 2024

    @newpavlov
    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.

  4. Pandapip1 commented on Apr 12, 2026

    @Pandapip1

    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.

    Okay, but if that's the case then Zeroizing shouldn't implement Debug at all then. If I submitted a PR that added this as an optional feature, would it likely be accepted?

  5. tarcieri commented on Apr 14, 2026

    @tarcieri
    Member

    Please don't add additional dependencies to zeroize, especially for something as trivial as opaque-debug

  6. Pandapip1 commented on Apr 16, 2026

    @Pandapip1

    From opaque-debug:

    This crate is deprecated. Use explicit impl of fmt::Debug instead.

    I'm not suggesting to add additional dependencies, I'm suggesting that the (optional!) feature be added.

  7. added a commit that references this issue on Jun 13, 2026
    2afc28d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions