From 1b06e368be951f16e3433fca5b383f4ef03f51cb Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Wed, 24 Jul 2024 12:22:15 -0600 Subject: [PATCH] der: allow all blanket impls on `?Sized` types This fixes the `Tagged` and `Encode` trait impls on `str`, for example. Closes #1365 --- der/src/encode.rs | 7 +++++-- der/src/tag.rs | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/der/src/encode.rs b/der/src/encode.rs index 28d7cba77..eba1f262d 100644 --- a/der/src/encode.rs +++ b/der/src/encode.rs @@ -69,7 +69,7 @@ pub trait Encode { impl Encode for T where - T: EncodeValue + Tagged, + T: EncodeValue + Tagged + ?Sized, { /// Compute the length of this value in bytes when encoded as ASN.1 DER. fn encoded_len(&self) -> Result { @@ -109,7 +109,10 @@ pub trait EncodePem: Encode + PemLabel { } #[cfg(feature = "pem")] -impl EncodePem for T { +impl EncodePem for T +where + T: Encode + PemLabel + ?Sized, +{ fn to_pem(&self, line_ending: LineEnding) -> Result { let der_len = usize::try_from(self.encoded_len()?)?; let pem_len = pem::encapsulated_len(Self::PEM_LABEL, line_ending, der_len)?; diff --git a/der/src/tag.rs b/der/src/tag.rs index 80b797ca9..8c8490adf 100644 --- a/der/src/tag.rs +++ b/der/src/tag.rs @@ -26,7 +26,7 @@ pub trait Tagged { } /// Types which are [`FixedTag`] always have a known [`Tag`] type. -impl Tagged for T { +impl Tagged for T { fn tag(&self) -> Tag { T::TAG }