safelog: Provide Redacted.as_inner() and .as_ref()

Just like for Sensitive.
This commit is contained in:
Ian Jackson 2023-06-09 13:02:15 +01:00
parent c679e8706a
commit 57f295cc21
2 changed files with 14 additions and 0 deletions

1
crates/safelog/semver.md Normal file
View File

@ -0,0 +1 @@
ADDED: Redacted.as_inner() and as_ref()

View File

@ -268,6 +268,19 @@ impl<T: Redactable> Redacted<T> {
pub fn unwrap(self) -> T {
self.0
}
/// Converts `&Redacted<T>` to `Redacted<&T>`
pub fn as_ref(&self) -> Redacted<&T> {
Redacted(&self.0)
}
/// Return a reference to the inner value
//
// This isn't `AsRef` or `as_ref` because we don't want to offer "de-redaction"
// via what is usually a semantically-neutral interface.
pub fn as_inner(&self) -> &T {
&self.0
}
}
impl<T: Redactable> std::fmt::Display for Redacted<T> {