about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/arc.rs5
-rw-r--r--src/liballoc/boxed.rs10
-rw-r--r--src/liballoc/rc.rs5
3 files changed, 20 insertions, 0 deletions
diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs
index ceca44fc1ac..f66f1f13dcb 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 1529187da06..629adf4649d 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 3507f123a6f..2f0bf1281b3 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 }
+}