Skip to content

Commit f6ac678

Browse files
bschoenmaeckersMatthijsKok
authored andcommitted
Add AsRef implementations for Rc
1 parent 768dbde commit f6ac678

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

library/alloc/src/rc.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3655,6 +3655,27 @@ impl<T: ?Sized, A: Allocator> AsRef<T> for Rc<T, A> {
36553655
}
36563656
}
36573657

3658+
#[stable(feature = "smart_ptr_as_ref_str", since = "CURRENT_RUSTC_VERSION")]
3659+
impl<A: Allocator> AsRef<str> for Rc<String, A> {
3660+
fn as_ref(&self) -> &str {
3661+
self.deref().as_ref()
3662+
}
3663+
}
3664+
3665+
#[stable(feature = "smart_ptr_as_ref_str", since = "CURRENT_RUSTC_VERSION")]
3666+
impl<A: Allocator> AsRef<[u8]> for Rc<String, A> {
3667+
fn as_ref(&self) -> &[u8] {
3668+
self.deref().as_ref()
3669+
}
3670+
}
3671+
3672+
#[stable(feature = "smart_ptr_as_ref_str", since = "CURRENT_RUSTC_VERSION")]
3673+
impl<A: Allocator> AsRef<[u8]> for Rc<str, A> {
3674+
fn as_ref(&self) -> &[u8] {
3675+
self.deref().as_ref()
3676+
}
3677+
}
3678+
36583679
#[stable(feature = "pin", since = "1.33.0")]
36593680
impl<T: ?Sized, A: Allocator> Unpin for Rc<T, A> {}
36603681

0 commit comments

Comments
 (0)