Skip to content

Commit 5f59c46

Browse files
committed
rc: from_{owned,const} -> from_{send,freeze}
1 parent 8ec70ae commit 5f59c46

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

src/libextra/rc.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ impl<T> Rc<T> {
5353
}
5454

5555
impl<T: Send> Rc<T> {
56-
pub fn from_owned(value: T) -> Rc<T> {
56+
pub fn from_send(value: T) -> Rc<T> {
5757
unsafe { Rc::new(value) }
5858
}
5959
}
6060

6161
impl<T: Freeze> Rc<T> {
62-
pub fn from_const(value: T) -> Rc<T> {
62+
pub fn from_freeze(value: T) -> Rc<T> {
6363
unsafe { Rc::new(value) }
6464
}
6565
}
@@ -111,7 +111,7 @@ mod test_rc {
111111

112112
#[test]
113113
fn test_clone() {
114-
let x = Rc::from_owned(Cell::new(5));
114+
let x = Rc::from_send(Cell::new(5));
115115
let y = x.clone();
116116
do x.borrow().with_mut_ref |inner| {
117117
*inner = 20;
@@ -121,7 +121,7 @@ mod test_rc {
121121

122122
#[test]
123123
fn test_deep_clone() {
124-
let x = Rc::from_owned(Cell::new(5));
124+
let x = Rc::from_send(Cell::new(5));
125125
let y = x.deep_clone();
126126
do x.borrow().with_mut_ref |inner| {
127127
*inner = 20;
@@ -131,21 +131,21 @@ mod test_rc {
131131

132132
#[test]
133133
fn test_simple() {
134-
let x = Rc::from_const(5);
134+
let x = Rc::from_freeze(5);
135135
assert_eq!(*x.borrow(), 5);
136136
}
137137

138138
#[test]
139139
fn test_simple_clone() {
140-
let x = Rc::from_const(5);
140+
let x = Rc::from_freeze(5);
141141
let y = x.clone();
142142
assert_eq!(*x.borrow(), 5);
143143
assert_eq!(*y.borrow(), 5);
144144
}
145145

146146
#[test]
147147
fn test_destructor() {
148-
let x = Rc::from_owned(~5);
148+
let x = Rc::from_send(~5);
149149
assert_eq!(**x.borrow(), 5);
150150
}
151151
}
@@ -178,13 +178,13 @@ impl<T> RcMut<T> {
178178
}
179179

180180
impl<T: Send> RcMut<T> {
181-
pub fn from_owned(value: T) -> RcMut<T> {
181+
pub fn from_send(value: T) -> RcMut<T> {
182182
unsafe { RcMut::new(value) }
183183
}
184184
}
185185

186186
impl<T: Freeze> RcMut<T> {
187-
pub fn from_const(value: T) -> RcMut<T> {
187+
pub fn from_freeze(value: T) -> RcMut<T> {
188188
unsafe { RcMut::new(value) }
189189
}
190190
}
@@ -258,7 +258,7 @@ mod test_rc_mut {
258258

259259
#[test]
260260
fn test_clone() {
261-
let x = RcMut::from_owned(5);
261+
let x = RcMut::from_send(5);
262262
let y = x.clone();
263263
do x.with_mut_borrow |value| {
264264
*value = 20;
@@ -270,7 +270,7 @@ mod test_rc_mut {
270270

271271
#[test]
272272
fn test_deep_clone() {
273-
let x = RcMut::from_const(5);
273+
let x = RcMut::from_freeze(5);
274274
let y = x.deep_clone();
275275
do x.with_mut_borrow |value| {
276276
*value = 20;
@@ -282,7 +282,7 @@ mod test_rc_mut {
282282

283283
#[test]
284284
fn borrow_many() {
285-
let x = RcMut::from_owned(5);
285+
let x = RcMut::from_send(5);
286286
let y = x.clone();
287287

288288
do x.with_borrow |a| {
@@ -298,7 +298,7 @@ mod test_rc_mut {
298298

299299
#[test]
300300
fn modify() {
301-
let x = RcMut::from_const(5);
301+
let x = RcMut::from_freeze(5);
302302
let y = x.clone();
303303

304304
do y.with_mut_borrow |a| {
@@ -313,22 +313,22 @@ mod test_rc_mut {
313313

314314
#[test]
315315
fn release_immutable() {
316-
let x = RcMut::from_owned(5);
316+
let x = RcMut::from_send(5);
317317
do x.with_borrow |_| {}
318318
do x.with_mut_borrow |_| {}
319319
}
320320

321321
#[test]
322322
fn release_mutable() {
323-
let x = RcMut::from_const(5);
323+
let x = RcMut::from_freeze(5);
324324
do x.with_mut_borrow |_| {}
325325
do x.with_borrow |_| {}
326326
}
327327

328328
#[test]
329329
#[should_fail]
330330
fn frozen() {
331-
let x = RcMut::from_owned(5);
331+
let x = RcMut::from_send(5);
332332
let y = x.clone();
333333

334334
do x.with_borrow |_| {
@@ -340,7 +340,7 @@ mod test_rc_mut {
340340
#[test]
341341
#[should_fail]
342342
fn mutable_dupe() {
343-
let x = RcMut::from_const(5);
343+
let x = RcMut::from_freeze(5);
344344
let y = x.clone();
345345

346346
do x.with_mut_borrow |_| {
@@ -352,7 +352,7 @@ mod test_rc_mut {
352352
#[test]
353353
#[should_fail]
354354
fn mutable_freeze() {
355-
let x = RcMut::from_owned(5);
355+
let x = RcMut::from_send(5);
356356
let y = x.clone();
357357

358358
do x.with_mut_borrow |_| {
@@ -364,7 +364,7 @@ mod test_rc_mut {
364364
#[test]
365365
#[should_fail]
366366
fn restore_freeze() {
367-
let x = RcMut::from_const(5);
367+
let x = RcMut::from_freeze(5);
368368
let y = x.clone();
369369

370370
do x.with_borrow |_| {

src/test/compile-fail/rcmut-not-const-and-not-owned.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn o<T: Send>(_: &T) {}
1414
fn c<T: Freeze>(_: &T) {}
1515

1616
fn main() {
17-
let x = extra::rc::RcMut::from_owned(0);
17+
let x = extra::rc::RcMut::from_send(0);
1818
o(&x); //~ ERROR instantiating a type parameter with an incompatible type `extra::rc::RcMut<int>`, which does not fulfill `Send`
1919
c(&x); //~ ERROR instantiating a type parameter with an incompatible type `extra::rc::RcMut<int>`, which does not fulfill `Freeze`
2020
}

0 commit comments

Comments
 (0)