diff options
| author | Daniel Micay <danielmicay@gmail.com> | 2013-08-01 02:51:20 -0400 |
|---|---|---|
| committer | Daniel Micay <danielmicay@gmail.com> | 2013-08-01 04:39:00 -0400 |
| commit | 5f59c46e0f5605a0cc90ebdb26b4d258a8f7b43a (patch) | |
| tree | a642382ac27fced1c462830e069ff705fcd9d12a | |
| parent | 8ec70ae5de0e33ab62732c59b0b2b0620cb8dce9 (diff) | |
| download | rust-5f59c46e0f5605a0cc90ebdb26b4d258a8f7b43a.tar.gz rust-5f59c46e0f5605a0cc90ebdb26b4d258a8f7b43a.zip | |
rc: from_{owned,const} -> from_{send,freeze}
| -rw-r--r-- | src/libextra/rc.rs | 38 | ||||
| -rw-r--r-- | src/test/compile-fail/rcmut-not-const-and-not-owned.rs | 2 |
2 files changed, 20 insertions, 20 deletions
diff --git a/src/libextra/rc.rs b/src/libextra/rc.rs index 04d6b8ebca5..86fbbd4c3cc 100644 --- a/src/libextra/rc.rs +++ b/src/libextra/rc.rs @@ -53,13 +53,13 @@ impl<T> Rc<T> { } impl<T: Send> Rc<T> { - pub fn from_owned(value: T) -> Rc<T> { + pub fn from_send(value: T) -> Rc<T> { unsafe { Rc::new(value) } } } impl<T: Freeze> Rc<T> { - pub fn from_const(value: T) -> Rc<T> { + pub fn from_freeze(value: T) -> Rc<T> { unsafe { Rc::new(value) } } } @@ -111,7 +111,7 @@ mod test_rc { #[test] fn test_clone() { - let x = Rc::from_owned(Cell::new(5)); + let x = Rc::from_send(Cell::new(5)); let y = x.clone(); do x.borrow().with_mut_ref |inner| { *inner = 20; @@ -121,7 +121,7 @@ mod test_rc { #[test] fn test_deep_clone() { - let x = Rc::from_owned(Cell::new(5)); + let x = Rc::from_send(Cell::new(5)); let y = x.deep_clone(); do x.borrow().with_mut_ref |inner| { *inner = 20; @@ -131,13 +131,13 @@ mod test_rc { #[test] fn test_simple() { - let x = Rc::from_const(5); + let x = Rc::from_freeze(5); assert_eq!(*x.borrow(), 5); } #[test] fn test_simple_clone() { - let x = Rc::from_const(5); + let x = Rc::from_freeze(5); let y = x.clone(); assert_eq!(*x.borrow(), 5); assert_eq!(*y.borrow(), 5); @@ -145,7 +145,7 @@ mod test_rc { #[test] fn test_destructor() { - let x = Rc::from_owned(~5); + let x = Rc::from_send(~5); assert_eq!(**x.borrow(), 5); } } @@ -178,13 +178,13 @@ impl<T> RcMut<T> { } impl<T: Send> RcMut<T> { - pub fn from_owned(value: T) -> RcMut<T> { + pub fn from_send(value: T) -> RcMut<T> { unsafe { RcMut::new(value) } } } impl<T: Freeze> RcMut<T> { - pub fn from_const(value: T) -> RcMut<T> { + pub fn from_freeze(value: T) -> RcMut<T> { unsafe { RcMut::new(value) } } } @@ -258,7 +258,7 @@ mod test_rc_mut { #[test] fn test_clone() { - let x = RcMut::from_owned(5); + let x = RcMut::from_send(5); let y = x.clone(); do x.with_mut_borrow |value| { *value = 20; @@ -270,7 +270,7 @@ mod test_rc_mut { #[test] fn test_deep_clone() { - let x = RcMut::from_const(5); + let x = RcMut::from_freeze(5); let y = x.deep_clone(); do x.with_mut_borrow |value| { *value = 20; @@ -282,7 +282,7 @@ mod test_rc_mut { #[test] fn borrow_many() { - let x = RcMut::from_owned(5); + let x = RcMut::from_send(5); let y = x.clone(); do x.with_borrow |a| { @@ -298,7 +298,7 @@ mod test_rc_mut { #[test] fn modify() { - let x = RcMut::from_const(5); + let x = RcMut::from_freeze(5); let y = x.clone(); do y.with_mut_borrow |a| { @@ -313,14 +313,14 @@ mod test_rc_mut { #[test] fn release_immutable() { - let x = RcMut::from_owned(5); + let x = RcMut::from_send(5); do x.with_borrow |_| {} do x.with_mut_borrow |_| {} } #[test] fn release_mutable() { - let x = RcMut::from_const(5); + let x = RcMut::from_freeze(5); do x.with_mut_borrow |_| {} do x.with_borrow |_| {} } @@ -328,7 +328,7 @@ mod test_rc_mut { #[test] #[should_fail] fn frozen() { - let x = RcMut::from_owned(5); + let x = RcMut::from_send(5); let y = x.clone(); do x.with_borrow |_| { @@ -340,7 +340,7 @@ mod test_rc_mut { #[test] #[should_fail] fn mutable_dupe() { - let x = RcMut::from_const(5); + let x = RcMut::from_freeze(5); let y = x.clone(); do x.with_mut_borrow |_| { @@ -352,7 +352,7 @@ mod test_rc_mut { #[test] #[should_fail] fn mutable_freeze() { - let x = RcMut::from_owned(5); + let x = RcMut::from_send(5); let y = x.clone(); do x.with_mut_borrow |_| { @@ -364,7 +364,7 @@ mod test_rc_mut { #[test] #[should_fail] fn restore_freeze() { - let x = RcMut::from_const(5); + let x = RcMut::from_freeze(5); let y = x.clone(); do x.with_borrow |_| { diff --git a/src/test/compile-fail/rcmut-not-const-and-not-owned.rs b/src/test/compile-fail/rcmut-not-const-and-not-owned.rs index c27debdbc7f..d645f35d96d 100644 --- a/src/test/compile-fail/rcmut-not-const-and-not-owned.rs +++ b/src/test/compile-fail/rcmut-not-const-and-not-owned.rs @@ -14,7 +14,7 @@ fn o<T: Send>(_: &T) {} fn c<T: Freeze>(_: &T) {} fn main() { - let x = extra::rc::RcMut::from_owned(0); + let x = extra::rc::RcMut::from_send(0); o(&x); //~ ERROR instantiating a type parameter with an incompatible type `extra::rc::RcMut<int>`, which does not fulfill `Send` c(&x); //~ ERROR instantiating a type parameter with an incompatible type `extra::rc::RcMut<int>`, which does not fulfill `Freeze` } |
