Skip to content

Commit ee6a09d

Browse files
committed
Improve rustdocs for displaying secrets
Do minor improvements to the rustdocs to aid readability in the editor.
1 parent 181ca4e commit ee6a09d

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/secret.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,28 +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
/// ```
121121
/// # #[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-
/// );
122+
/// let key = secp256k1::ONE_KEY;
123+
///
124+
/// // Normal display hides value.
125+
/// assert_eq!("SecretKey(#2518682f7819fb2d)", format!("{:?}", key));
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())
137-
/// );
134+
/// format!("{:?}", key.display_secret()),
135+
/// format!("DisplaySecret(\"{}\")", key.display_secret()));
138136
/// # }
139137
/// ```
140138
#[inline]
@@ -172,6 +170,7 @@ impl KeyPair {
172170
/// "0000000000000000000000000000000000000000000000000000000000000001",
173171
/// format!("{}", key.display_secret())
174172
/// );
173+
/// // Also, we can explicitly display with `Debug`:
175174
/// assert_eq!(
176175
/// "DisplaySecret(\"0000000000000000000000000000000000000000000000000000000000000001\")",
177176
/// format!("{:?}", key.display_secret())

0 commit comments

Comments
 (0)