x_core/
debug_ignore.rs

1// Copyright (c) The Diem Core Contributors
2// SPDX-License-Identifier: Apache-2.0
3
4use std::{
5    fmt,
6    ops::{Deref, DerefMut},
7};
8
9/// A newtype wrapper that causes this field to be ignored while being debugged.
10///
11/// Similar to `#[derivative(ignore)]` from the `derivative` crate, but avoids an extra dependency.
12#[derive(Copy, Clone, Eq, Hash, Ord, PartialEq, PartialOrd)]
13pub struct DebugIgnore<T>(pub T);
14
15impl<T> Deref for DebugIgnore<T> {
16    type Target = T;
17
18    fn deref(&self) -> &Self::Target {
19        &self.0
20    }
21}
22
23impl<T> DerefMut for DebugIgnore<T> {
24    fn deref_mut(&mut self) -> &mut Self::Target {
25        &mut self.0
26    }
27}
28
29impl<T> fmt::Debug for DebugIgnore<T> {
30    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
31        write!(f, "...")
32    }
33}