Skip to content

Commit c8b33d5

Browse files
committed
review: Bounded Default impl + simplified call site
1 parent 6952829 commit c8b33d5

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

rust/operator-binary/src/format/convert.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@ pub fn convert(
2222
(WellKnownSecretData::TlsPem(pem), SecretFormat::TlsPkcs12) => {
2323
Ok(WellKnownSecretData::TlsPkcs12(convert_tls_to_pkcs12(
2424
pem,
25-
compat
26-
.tls_pkcs12_password
27-
.as_deref()
28-
.map_or("", String::as_str),
25+
&compat.tls_pkcs12_password.unwrap_or_default(),
2926
)?))
3027
}
3128

rust/operator-binary/src/utils.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,17 @@ pub fn asn1time_to_offsetdatetime(asn: &Asn1TimeRef) -> Result<OffsetDateTime, A
179179

180180
/// Wrapper for (mostly) secret values that should not be logged.
181181
// When/if migrating to Valuable, provide a dummy implementation of Value too
182-
#[derive(Default)]
183182
pub struct Unloggable<T>(pub T);
184183

184+
impl<T> Default for Unloggable<T>
185+
where
186+
T: Default,
187+
{
188+
fn default() -> Self {
189+
Self(T::default())
190+
}
191+
}
192+
185193
impl<T> Debug for Unloggable<T> {
186194
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
187195
f.write_str("<redacted>")

0 commit comments

Comments
 (0)