Skip to content

Commit

Permalink
Implement SerializableSecret for &Secret<T>
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeMathWalker authored Apr 22, 2024
1 parent 5a41701 commit ed02692
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ pub trait SerializableSecret<T> {
fn expose_via(&self, expose: impl Fn(&Secret<T>) -> &T) -> Self::Exposed<'_>;
}

impl<T: Serialize> SerializableSecret<T> for &Secret<T> {
type Exposed<'a> = &'a T where T: 'a;

fn expose_via(&self, expose: impl Fn(&Secret<T>) -> &T) -> Self::Exposed<'_> {
expose(self)
}
}

impl<T: Serialize> SerializableSecret<T> for Secret<T> {
type Exposed<'a> = &'a T where T: 'a;

Expand Down

0 comments on commit ed02692

Please sign in to comment.