Skip to content

Commit cc2d49a

Browse files
WhatAmISupposedToPutHerejannau
authored andcommitted
rust: alloc: kbox: Add AsRef implementation to Box
Signed-off-by: Sasha Finkelstein <fnkl.kernel@gmail.com>
1 parent ad45f34 commit cc2d49a

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

rust/kernel/alloc/kbox.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,3 +536,13 @@ where
536536
unsafe { A::free(self.0.cast(), layout) };
537537
}
538538
}
539+
540+
impl<T, A> AsRef<T> for Box<T, A>
541+
where
542+
T: ?Sized,
543+
A: Allocator,
544+
{
545+
fn as_ref(&self) -> &T {
546+
&**self
547+
}
548+
}

0 commit comments

Comments
 (0)