1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
//! Derive Debug for types where not all fields implement Debug.
//!
//! This crate works on stable and with `no_std`.
//! On nightly the `unstable` feature can be used for specialization based trait detection and/or `..` formatting.
//!
//! ### Placeholder with Type Info
//!
//! ```
//! use partialdebug::placeholder::PartialDebug;
//!
//! # struct DNA;
//! #
//! #[derive(PartialDebug)]
//! struct Dog {
//! legs: usize,
//! eyes: usize,
//! dna: DNA,
//! }
//!
//! # impl Dog {
//! # fn new() -> Dog {
//! # Dog {
//! # legs: 4,
//! # eyes: 2,
//! # dna: DNA,
//! # }
//! # }
//! # }
//! #
//! assert_eq!(format!("{:?}", Dog::new()), "Dog { legs: 4, eyes: 2, dna: DNA }");
//! ```
//!
//! ### Placeholder with Custom Text
//!
//! ```
//! use partialdebug::placeholder::PartialDebug;
//!
//! # struct DNA;
//! #
//! #[derive(PartialDebug)]
//! #[debug_placeholder = "Unknown"]
//! struct Dog {
//! legs: usize,
//! eyes: usize,
//! dna: DNA,
//! }
//!
//! # impl Dog {
//! # fn new() -> Dog {
//! # Dog {
//! # legs: 4,
//! # eyes: 2,
//! # dna: DNA,
//! # }
//! # }
//! # }
//! #
//! assert_eq!(format!("{:?}", Dog::new()), "Dog { legs: 4, eyes: 2, dna: Unknown }");
//! ```
//!
//! ### Non Exhaustive
//!
//! Only available on nightly after setting the `unstable` feature.
//!
//! Requires the `debug_non_exhaustive` feature to be enabled in user code.
//!
//! Only available for structs with named fields.
//! ### Caveats
//!
//! Trait detection for generic types requires specialization.
//! To enable specialization based trait detection use a nightly compiler and enable the `unstable` feature.
//!
//! ```
//! use partialdebug::placeholder::PartialDebug;
//!
//! #[derive(PartialDebug)]
//! struct Container<T>(T);
//!
//! #[cfg(feature = "unstable")]
//! assert_eq!(format!("{:?}", Container(42)), "Container(42)");
//! #[cfg(not(feature = "unstable"))]
//! assert_eq!(format!("{:?}", Container(42)), "Container(T)");
//! ```
use ;
/// Placeholder struct for types that do not implement Debug
/// ```
/// # use partialdebug::Placeholder;
/// assert_eq!(format!("{:?}", Placeholder("Foo")), "Foo")
/// ```
;
/// Trait detection logic using specialization
/// The placeholder version of `PartialDebug`
/// The non exhaustive version of `PartialDebug`