Skip to content

Commit 768dbde

Browse files
committed
Add AsRef implementations for Box
1 parent b6d74b5 commit 768dbde

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

library/alloc/src/boxed.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2043,6 +2043,13 @@ impl<T: ?Sized, A: Allocator> AsRef<T> for Box<T, A> {
20432043
}
20442044
}
20452045

2046+
#[stable(feature = "smart_ptr_as_ref_str", since = "CURRENT_RUSTC_VERSION")]
2047+
impl<A: Allocator> AsRef<[u8]> for Box<str, A> {
2048+
fn as_ref(&self) -> &[u8] {
2049+
self.deref().as_ref()
2050+
}
2051+
}
2052+
20462053
#[stable(since = "1.5.0", feature = "smart_ptr_as_ref")]
20472054
impl<T: ?Sized, A: Allocator> AsMut<T> for Box<T, A> {
20482055
fn as_mut(&mut self) -> &mut T {

0 commit comments

Comments
 (0)