Skip to content

Commit ad7dacd

Browse files
committed
Implemented BorrowFrom<Rc<T>> for T.
1 parent 2e996ff commit ad7dacd

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/liballoc/rc.rs

+7
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@
141141
142142
#![stable]
143143

144+
use core::borrow::BorrowFrom;
144145
use core::cell::Cell;
145146
use core::clone::Clone;
146147
use core::cmp::{PartialEq, PartialOrd, Eq, Ord, Ordering};
@@ -349,6 +350,12 @@ impl<T: Clone> Rc<T> {
349350
}
350351
}
351352

353+
impl<T> BorrowFrom<Rc<T>> for T {
354+
fn borrow_from(owned: &Rc<T>) -> &T {
355+
&**owned
356+
}
357+
}
358+
352359
#[experimental = "Deref is experimental."]
353360
impl<T> Deref<T> for Rc<T> {
354361
#[inline(always)]

0 commit comments

Comments
 (0)