@@ -113,27 +113,26 @@ impl SecretKey {
113113 /// little-endian hexadecimal string using the provided formatter.
114114 ///
115115 /// 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 .
117117 ///
118- /// # Example
118+ /// # Examples
119119 ///
120120 /// ```
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+ ///
129127 /// // Here we explicitly display the secret value:
130128 /// assert_eq!(
131129 /// "0000000000000000000000000000000000000000000000000000000000000001",
132130 /// format!("{}", key.display_secret())
133131 /// );
132+ /// // Also, we can explicitly display with `Debug`:
134133 /// assert_eq!(
135- /// "DisplaySecret(\"0000000000000000000000000000000000000000000000000000000000000001\")" ,
136- /// format!("{:?} ", key.display_secret())
134+ /// format!("{:?}", key.display_secret()) ,
135+ /// format!("DisplaySecret(\"{}\") ", key.display_secret())
137136 /// );
138137 /// # }
139138 /// ```
@@ -153,28 +152,23 @@ impl KeyPair {
153152 /// # Example
154153 ///
155154 /// ```
156- /// # #[cfg(all( feature = "std", not(feature = "bitcoin_hashes")) )] {
155+ /// # #[cfg(feature = "std")] {
157156 /// use secp256k1::ONE_KEY;
158157 /// use secp256k1::KeyPair;
159158 /// use secp256k1::Secp256k1;
160159 ///
161160 /// let secp = Secp256k1::new();
162161 /// let key = ONE_KEY;
163162 /// let key = KeyPair::from_secret_key(&secp, key);
164- ///
165- /// // Normal display hides value
166- /// assert_eq!(
167- /// "KeyPair(#2518682f7819fb2d)",
168- /// format!("{:?}", key)
169- /// );
170163 /// // Here we explicitly display the secret value:
171164 /// assert_eq!(
172165 /// "0000000000000000000000000000000000000000000000000000000000000001",
173166 /// format!("{}", key.display_secret())
174167 /// );
168+ /// // Also, we can explicitly display with `Debug`:
175169 /// assert_eq!(
176- /// "DisplaySecret(\"0000000000000000000000000000000000000000000000000000000000000001\")" ,
177- /// format!("{:?} ", key.display_secret())
170+ /// format!("{:?}", key.display_secret()) ,
171+ /// format!("DisplaySecret(\"{}\") ", key.display_secret())
178172 /// );
179173 /// # }
180174 /// ```
0 commit comments