pub struct Secret<T> { /* private fields */ }
Expand description
A wrapper for values that should not be printed.
This type does not implement Display
, and has a Debug
impl that hides
the contained value.
let token = Secret::from("super secret string");
assert_eq!(format!("{:?}", token), "Secret { inner: \"REDACTED\" }");
Currently, we write a borrowed Secret<T>
as Secret<&T>
.
The as_deref
and owned
methods can
be used to convert back and forth between Secret<String>
and Secret<&str>
.
Implementations§
source§impl<T> Secret<T>
impl<T> Secret<T>
sourcepub fn expose(self) -> T
pub fn expose(self) -> T
Unwraps the contained value.
Use of this method marks the boundary of where the contained value is hidden.
Trait Implementations§
source§impl<T: PartialEq> PartialEq<Secret<T>> for Secret<T>
impl<T: PartialEq> PartialEq<Secret<T>> for Secret<T>
impl<T: Eq> Eq for Secret<T>
impl<T> StructuralEq for Secret<T>
impl<T> StructuralPartialEq for Secret<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for Secret<T>where T: RefUnwindSafe,
impl<T> Send for Secret<T>where T: Send,
impl<T> Sync for Secret<T>where T: Sync,
impl<T> Unpin for Secret<T>where T: Unpin,
impl<T> UnwindSafe for Secret<T>where T: UnwindSafe,
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.