Skip to content

Commit a56cba4

Browse files
committed
Add a default impl for 'DebugSecret' trait
By using a default implementation of the trait's function 'debug_secret()', downstream users don't have to define the function themselves. They can simply: impl DebugSecret for MyType {} and the static string returned will be the default one. Downstream users can still add a full 'debug_secret()' definition to the trait impl to change the string used.
1 parent f7a93eb commit a56cba4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

secrecy/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,7 @@ pub trait DebugSecret {
104104
/// Information about what the secret contains.
105105
///
106106
/// Static so as to discourage unintentional secret exposure.
107-
fn debug_secret() -> &'static str;
107+
fn debug_secret() -> &'static str {
108+
"[SECRET]"
109+
}
108110
}

0 commit comments

Comments
 (0)