]> git.lizzy.rs Git - rust.git/commitdiff
Implemented BorrowFrom<Rc<T>> for T.
authorAaron Weiss <aaronweiss74@gmail.com>
Mon, 8 Dec 2014 20:56:10 +0000 (15:56 -0500)
committerAaron Weiss <aaronweiss74@gmail.com>
Mon, 8 Dec 2014 21:32:08 +0000 (16:32 -0500)
src/liballoc/rc.rs

index 53891583edb20c768fa2068498511b8a76b2c5b8..217c898e661a0596c2470c149b57201f2df7c72d 100644 (file)
 
 #![stable]
 
+use core::borrow::BorrowFrom;
 use core::cell::Cell;
 use core::clone::Clone;
 use core::cmp::{PartialEq, PartialOrd, Eq, Ord, Ordering};
@@ -349,6 +350,12 @@ pub fn make_unique(&mut self) -> &mut T {
     }
 }
 
+impl<T> BorrowFrom<Rc<T>> for T {
+    fn borrow_from(owned: &Rc<T>) -> &T {
+        &**owned
+    }
+}
+
 #[experimental = "Deref is experimental."]
 impl<T> Deref<T> for Rc<T> {
     #[inline(always)]