Skip to content

Commit

Permalink
Merge pull request #61 from LukeMathWalker/patch-1
Browse files Browse the repository at this point in the history
Implement `SerializableSecret` for &Secret<T>
  • Loading branch information
eopb authored May 11, 2024
2 parents 5a41701 + ed02692 commit 3e9c3f6
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 3e9c3f6

Please sign in to comment.