]> git.lizzy.rs Git - rust.git/blobdiff - src/liballoc/arc.rs
Added AsRef implementations for Arc and Rc
[rust.git] / src / liballoc / arc.rs
index 593ecc72d50cd00379065dba912c00333742ef39..d12d28335dde606917bd6ab8cccec2389ce40f90 100644 (file)
@@ -332,6 +332,15 @@ fn deref(&self) -> &T {
     }
 }
 
+#[stable(feature = "rc_arc_as_ref", since = "1.2.0")]
+impl<T: ?Sized> AsRef<T> for Arc<T> {
+
+    #[inline]
+    fn as_ref(&self) -> &T {
+        &self.inner().data
+    }
+}
+
 impl<T: Clone> Arc<T> {
     /// Make a mutable reference from the given `Arc<T>`.
     ///