Skip to content

Commit c30b48e

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

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
@@ -485,3 +485,13 @@ where
485485
unsafe { A::free(self.0.cast(), layout) };
486486
}
487487
}
488+
489+
impl<T, A> AsRef<T> for Box<T, A>
490+
where
491+
T: ?Sized,
492+
A: Allocator,
493+
{
494+
fn as_ref(&self) -> &T {
495+
&**self
496+
}
497+
}

0 commit comments

Comments
 (0)