]> git.lizzy.rs Git - rust.git/blobdiff - src/liballoc/boxed.rs
std: Add AsRef/AsMut impls to Box/Rc/Arc
[rust.git] / src / liballoc / boxed.rs
index 1529187da064c05550974edc92755fdb91ead193..629adf4649d38c8147650d97e58ab1a6959c7cf0 100644 (file)
@@ -594,3 +594,13 @@ fn borrow_mut(&mut self) -> &mut 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 }
+}