Skip to content

Commit 15b98d9

Browse files
committed
---
yaml --- r: 106606 b: refs/heads/try c: 52532d1 h: refs/heads/master v: v3
1 parent 80b7d8d commit 15b98d9

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: b8ef9fd9c9f642ce7b8aed82782a1ed745d08d64
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: b8601a3d8b91ad3b653d143307611f2f5c75617e
5-
refs/heads/try: 3b125ff3bbe77a8601ba2d424e8aa6f254abfd19
5+
refs/heads/try: 52532d13a6e72e4bf7f931a93f902de47d667baf
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libstd/cell.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use clone::{Clone, DeepClone};
1515
use cmp::Eq;
1616
use fmt;
1717
use kinds::{marker, Pod};
18-
use ops::Drop;
18+
use ops::{Deref, DerefMut, Drop};
1919
use option::{None, Option, Some};
2020

2121
/// A mutable memory location that admits only `Pod` data.
@@ -258,6 +258,13 @@ impl<'b, T> Ref<'b, T> {
258258
}
259259
}
260260

261+
impl<'b, T> Deref<T> for Ref<'b, T> {
262+
#[inline]
263+
fn deref<'a>(&'a self) -> &'a T {
264+
&self.parent.value
265+
}
266+
}
267+
261268
/// Wraps a mutable borrowed reference to a value in a `RefCell` box.
262269
pub struct RefMut<'b, T> {
263270
priv parent: &'b mut RefCell<T>
@@ -279,6 +286,20 @@ impl<'b, T> RefMut<'b, T> {
279286
}
280287
}
281288

289+
impl<'b, T> Deref<T> for RefMut<'b, T> {
290+
#[inline]
291+
fn deref<'a>(&'a self) -> &'a T {
292+
&self.parent.value
293+
}
294+
}
295+
296+
impl<'b, T> DerefMut<T> for RefMut<'b, T> {
297+
#[inline]
298+
fn deref_mut<'a>(&'a mut self) -> &'a mut T {
299+
&mut self.parent.value
300+
}
301+
}
302+
282303
#[cfg(test)]
283304
mod test {
284305
use super::*;

branches/try/src/libstd/rc.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use cast::transmute;
2727
use clone::{Clone, DeepClone};
2828
use cmp::{Eq, Ord};
2929
use kinds::marker;
30-
use ops::Drop;
30+
use ops::{Deref, Drop};
3131
use option::{Option, Some, None};
3232
use ptr;
3333
use rt::global_heap::exchange_free;
@@ -78,6 +78,14 @@ impl<T> Rc<T> {
7878
}
7979
}
8080

81+
impl<T> Deref<T> for Rc<T> {
82+
/// Borrow the value contained in the reference-counted box
83+
#[inline(always)]
84+
fn deref<'a>(&'a self) -> &'a T {
85+
unsafe { &(*self.ptr).value }
86+
}
87+
}
88+
8189
#[unsafe_destructor]
8290
impl<T> Drop for Rc<T> {
8391
fn drop(&mut self) {

0 commit comments

Comments
 (0)