@@ -113,27 +113,26 @@ impl SecretKey {
113
113
/// little-endian hexadecimal string using the provided formatter.
114
114
///
115
115
/// This is the only method that outputs the actual secret key value, and, thus,
116
- /// should be used with extreme precaution .
116
+ /// should be used with extreme caution .
117
117
///
118
- /// # Example
118
+ /// # Examples
119
119
///
120
120
/// ```
121
- /// # #[cfg(all(feature = "std", not(feature = "bitcoin_hashes")))] {
122
- /// use secp256k1::ONE_KEY;
123
- /// let key = ONE_KEY;
124
- /// // Normal display hides value
125
- /// assert_eq!(
126
- /// "SecretKey(#2518682f7819fb2d)",
127
- /// format!("{:?}", key)
128
- /// );
121
+ /// # #[cfg(feature = "std")] {
122
+ /// let key = secp256k1::ONE_KEY;
123
+ ///
124
+ /// // Normal debug hides value (`Display` is not implemented for `SecretKey`).
125
+ /// // E.g., `format!("{:?}", key)` prints "SecretKey(#2518682f7819fb2d)".
126
+ ///
129
127
/// // Here we explicitly display the secret value:
130
128
/// assert_eq!(
131
129
/// "0000000000000000000000000000000000000000000000000000000000000001",
132
130
/// format!("{}", key.display_secret())
133
131
/// );
132
+ /// // Also, we can explicitly display with `Debug`:
134
133
/// assert_eq!(
135
- /// "DisplaySecret(\"0000000000000000000000000000000000000000000000000000000000000001\")" ,
136
- /// format!("{:?} ", key.display_secret())
134
+ /// format!("{:?}", key.display_secret()) ,
135
+ /// format!("DisplaySecret(\"{}\") ", key.display_secret())
137
136
/// );
138
137
/// # }
139
138
/// ```
@@ -153,28 +152,23 @@ impl KeyPair {
153
152
/// # Example
154
153
///
155
154
/// ```
156
- /// # #[cfg(all( feature = "std", not(feature = "bitcoin_hashes")) )] {
155
+ /// # #[cfg(feature = "std")] {
157
156
/// use secp256k1::ONE_KEY;
158
157
/// use secp256k1::KeyPair;
159
158
/// use secp256k1::Secp256k1;
160
159
///
161
160
/// let secp = Secp256k1::new();
162
161
/// let key = ONE_KEY;
163
162
/// let key = KeyPair::from_secret_key(&secp, key);
164
- ///
165
- /// // Normal display hides value
166
- /// assert_eq!(
167
- /// "KeyPair(#2518682f7819fb2d)",
168
- /// format!("{:?}", key)
169
- /// );
170
163
/// // Here we explicitly display the secret value:
171
164
/// assert_eq!(
172
165
/// "0000000000000000000000000000000000000000000000000000000000000001",
173
166
/// format!("{}", key.display_secret())
174
167
/// );
168
+ /// // Also, we can explicitly display with `Debug`:
175
169
/// assert_eq!(
176
- /// "DisplaySecret(\"0000000000000000000000000000000000000000000000000000000000000001\")" ,
177
- /// format!("{:?} ", key.display_secret())
170
+ /// format!("{:?}", key.display_secret()) ,
171
+ /// format!("DisplaySecret(\"{}\") ", key.display_secret())
178
172
/// );
179
173
/// # }
180
174
/// ```
0 commit comments