Skip to content

Commit 9563a33

Browse files
committed
---
yaml --- r: 149746 b: refs/heads/try2 c: 52532d1 h: refs/heads/master v: v3
1 parent d5a713c commit 9563a33

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
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 3b125ff3bbe77a8601ba2d424e8aa6f254abfd19
8+
refs/heads/try2: 52532d13a6e72e4bf7f931a93f902de47d667baf
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/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/try2/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)