diff --git a/src/pool/mod.rs b/src/pool/mod.rs index f7441e23..3e720860 100644 --- a/src/pool/mod.rs +++ b/src/pool/mod.rs @@ -439,6 +439,24 @@ unsafe impl Sync for Box where T: Sync {} unsafe impl stable_deref_trait::StableDeref for Box {} +impl AsRef<[T]> for Box +where + A: AsRef<[T]>, +{ + fn as_ref(&self) -> &[T] { + self.deref().as_ref() + } +} + +impl AsMut<[T]> for Box +where + A: AsMut<[T]>, +{ + fn as_mut(&mut self) -> &mut [T] { + self.deref_mut().as_mut() + } +} + impl Deref for Box { type Target = T; diff --git a/src/pool/singleton.rs b/src/pool/singleton.rs index ccc2d966..62de8c8f 100644 --- a/src/pool/singleton.rs +++ b/src/pool/singleton.rs @@ -244,6 +244,26 @@ where { } +impl AsRef<[T]> for Box

+where + P: Pool, + P::Data: AsRef<[T]>, +{ + fn as_ref(&self) -> &[T] { + self.deref().as_ref() + } +} + +impl AsMut<[T]> for Box

+where + P: Pool, + P::Data: AsMut<[T]>, +{ + fn as_mut(&mut self) -> &mut [T] { + self.deref_mut().as_mut() + } +} + impl

PartialEq for Box

where P: Pool,