secret!() { /* proc-macro */ }Expand description
Generate a new type for a secret
The secret! macro generates a new type for secrets such as passwords and API tokens. The type
uses the secrecy crate internally to prevent accidentally
leaking the inner value in debug or log statements.
The new type implements common traits like Display and From<&str> and From<String>. The
inner value can be revealed using the expose method.
ยงExample
use typed_fields::secret;
secret!(ApiToken);
let token: ApiToken = "super-secret-api-token".into();
let header = format!("Authorization: Bearer {}", token.expose());