diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index ceca44fc1ac29..f66f1f13dcb23 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -1148,3 +1148,8 @@ impl<T: ?Sized> borrow::Borrow<T> for Arc<T> { &**self } } + +#[stable(since = "1.5.0", feature = "smart_ptr_as_ref")] +impl<T: ?Sized> AsRef<T> for Arc<T> { + fn as_ref(&self) -> &T { &**self } +} diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 1529187da064c..629adf4649d38 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -594,3 +594,13 @@ impl<T: ?Sized> borrow::BorrowMut<T> for Box<T> { &mut **self } } + +#[stable(since = "1.5.0", feature = "smart_ptr_as_ref")] +impl<T: ?Sized> AsRef<T> for Box<T> { + fn as_ref(&self) -> &T { &**self } +} + +#[stable(since = "1.5.0", feature = "smart_ptr_as_ref")] +impl<T: ?Sized> AsMut<T> for Box<T> { + fn as_mut(&mut self) -> &mut T { &mut **self } +} diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 3507f123a6f15..2f0bf1281b344 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -1117,3 +1117,8 @@ impl<T: ?Sized> borrow::Borrow<T> for Rc<T> { &**self } } + +#[stable(since = "1.5.0", feature = "smart_ptr_as_ref")] +impl<T: ?Sized> AsRef<T> for Rc<T> { + fn as_ref(&self) -> &T { &**self } +}