Skip to content

Commit 940ac64

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

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
@@ -457,3 +457,13 @@ where
457457

458458
//#[unstable(feature = "coerce_unsized", issue = "18598")]
459459
impl<T: ?Sized + Unsize<U>, U: ?Sized, A: Allocator> CoerceUnsized<Box<U, A>> for Box<T, A> {}
460+
461+
impl<T, A> AsRef<T> for Box<T, A>
462+
where
463+
T: ?Sized,
464+
A: Allocator,
465+
{
466+
fn as_ref(&self) -> &T {
467+
&*self
468+
}
469+
}

0 commit comments

Comments
 (0)