opaque_debug/
lib.rs

1//! Macro for opaque `Debug` trait implementation.
2#![no_std]
3
4#[doc(hidden)]
5pub extern crate core as __core;
6
7/// Macro for defining opaque `Debug` implementation.
8///
9/// It will use the following format: "StructName { ... }". While it's
10/// convinient to have it (e.g. for including into other structs), it could be
11/// undesirable to leak internal state, which can happen for example through
12/// uncareful logging.
13#[macro_export]
14macro_rules! implement {
15    ($struct:ty) => {
16        impl $crate::__core::fmt::Debug for $struct {
17            fn fmt(&self, f: &mut $crate::__core::fmt::Formatter)
18                -> Result<(), $crate::__core::fmt::Error>
19            {
20                write!(f, concat!(stringify!($struct), " {{ ... }}"))
21            }
22        }
23    }
24}