Skip to content

Commit f2a13e5

Browse files
committed
---
yaml --- r: 89992 b: refs/heads/master c: c6ca9ab h: refs/heads/master v: v3
1 parent 9ed9f5a commit f2a13e5

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 48cd8c646ace585153d6ed25baccdd8420742e42
2+
refs/heads/master: c6ca9abcc651423fe85f522cbd20f1e64463c36f
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d3e57dca68fde4effdda3e4ae2887aa535fcd6
55
refs/heads/try: b160761e35efcd1207112b3b782c06633cf441a8

trunk/src/libstd/rc.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use unstable::intrinsics::transmute;
2121
use ops::Drop;
2222
use kinds::{Freeze, Send};
2323
use clone::{Clone, DeepClone};
24+
use mutable::Mut;
2425

2526
struct RcBox<T> {
2627
value: T,
@@ -54,6 +55,16 @@ impl<T: Send> Rc<T> {
5455
}
5556
}
5657

58+
impl<T: Freeze> Rc<Mut<T>> {
59+
/// Construct a new reference-counted box from a `Mut`-wrapped `Freeze` value
60+
#[inline]
61+
pub fn from_mut(value: Mut<T>) -> Rc<Mut<T>> {
62+
unsafe {
63+
Rc::new_unchecked(value)
64+
}
65+
}
66+
}
67+
5768
impl<T> Rc<T> {
5869
/// Unsafety construct a new reference-counted box from any value.
5970
///
@@ -146,4 +157,10 @@ mod test_rc {
146157
let x = Rc::from_send(~5);
147158
assert_eq!(**x.borrow(), 5);
148159
}
160+
161+
#[test]
162+
fn test_from_mut() {
163+
let a = 10;
164+
let _x = Rc::from_mut(Mut::new(&a));
165+
}
149166
}

0 commit comments

Comments
 (0)