diff options
Diffstat (limited to 'vendor/der/src/referenced.rs')
-rw-r--r-- | vendor/der/src/referenced.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/vendor/der/src/referenced.rs b/vendor/der/src/referenced.rs index bb920db3a..b0c8f0325 100644 --- a/vendor/der/src/referenced.rs +++ b/vendor/der/src/referenced.rs @@ -45,3 +45,25 @@ where self.as_ref().map(|o| o.ref_to_owned()) } } + +#[cfg(feature = "alloc")] +mod allocating { + use super::{OwnedToRef, RefToOwned}; + use alloc::boxed::Box; + + impl<'a> RefToOwned<'a> for &'a [u8] { + type Owned = Box<[u8]>; + + fn ref_to_owned(&self) -> Self::Owned { + Box::from(*self) + } + } + + impl OwnedToRef for Box<[u8]> { + type Borrowed<'a> = &'a [u8]; + + fn owned_to_ref(&self) -> Self::Borrowed<'_> { + self.as_ref() + } + } +} |