Skip to content

Commit

Permalink
Merge pull request #55 from eopb/push-kxklklmqkwly
Browse files Browse the repository at this point in the history
refactor: fix clippy lints
  • Loading branch information
eopb authored Mar 23, 2024
2 parents bfa5e19 + ba16120 commit 917558a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ impl<T> Secret<T> {
Self(secret.into())
}
#[inline]
#[must_use]
pub fn try_from<U: TryInto<T>>(secret: U) -> Result<Self, Secret<U::Error>> {
secret.try_into().map(Self).map_err(Secret)
}
Expand Down
6 changes: 3 additions & 3 deletions src/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ pub trait SerializableSecret<T> {
Self: 'a;
/// To reduce the number of functions that are able to expose secrets we require
/// that the [`Secret::expose_secret`] function is passed in here.
fn expose_via<'a>(&'a self, expose: impl Fn(&Secret<T>) -> &T) -> Self::Exposed<'a>;
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<'a>(&'a self, expose: impl Fn(&Secret<T>) -> &T) -> Self::Exposed<'a> {
fn expose_via(&self, expose: impl Fn(&Secret<T>) -> &T) -> Self::Exposed<'_> {
expose(self)
}
}

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

fn expose_via<'a>(&'a self, expose: impl Fn(&Secret<T>) -> &T) -> Self::Exposed<'a> {
fn expose_via(&self, expose: impl Fn(&Secret<T>) -> &T) -> Self::Exposed<'_> {
self.as_ref().map(expose)
}
}
Expand Down

0 comments on commit 917558a

Please sign in to comment.