Skip to content

Commit 618eebf

Browse files
committed
AsRef, AsMut for pool
1 parent e0b3b3a commit 618eebf

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/pool/mod.rs

+18
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,24 @@ unsafe impl<T, S> Sync for Box<T, S> where T: Sync {}
439439

440440
unsafe impl<T> stable_deref_trait::StableDeref for Box<T> {}
441441

442+
impl<A, T> AsRef<[T]> for Box<A>
443+
where
444+
A: AsRef<[T]>,
445+
{
446+
fn as_ref(&self) -> &[T] {
447+
self.deref().as_ref()
448+
}
449+
}
450+
451+
impl<A, T> AsMut<[T]> for Box<A>
452+
where
453+
A: AsMut<[T]>,
454+
{
455+
fn as_mut(&mut self) -> &mut [T] {
456+
self.deref_mut().as_mut()
457+
}
458+
}
459+
442460
impl<T> Deref for Box<T> {
443461
type Target = T;
444462

src/pool/singleton.rs

+20
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,26 @@ where
244244
{
245245
}
246246

247+
impl<P, T> AsRef<[T]> for Box<P>
248+
where
249+
P: Pool,
250+
P::Data: AsRef<[T]>,
251+
{
252+
fn as_ref(&self) -> &[T] {
253+
self.deref().as_ref()
254+
}
255+
}
256+
257+
impl<P, T> AsMut<[T]> for Box<P>
258+
where
259+
P: Pool,
260+
P::Data: AsMut<[T]>,
261+
{
262+
fn as_mut(&mut self) -> &mut [T] {
263+
self.deref_mut().as_mut()
264+
}
265+
}
266+
247267
impl<P> PartialEq for Box<P>
248268
where
249269
P: Pool,

0 commit comments

Comments
 (0)