diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2014-05-05 18:56:44 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2014-05-06 23:12:54 -0700 |
| commit | 090040bf4037a094e50b03d79e4baf5cd89c912b (patch) | |
| tree | 27fa91d623889d59260d3db167abdfa8c4288849 /src/libstd/clone.rs | |
| parent | 24f6f26e633e50b5b59f9d0f6cca0b1e49e215d9 (diff) | |
| download | rust-090040bf4037a094e50b03d79e4baf5cd89c912b.tar.gz rust-090040bf4037a094e50b03d79e4baf5cd89c912b.zip | |
librustc: Remove `~EXPR`, `~TYPE`, and `~PAT` from the language, except
for `~str`/`~[]`. Note that `~self` still remains, since I forgot to add support for `Box<self>` before the snapshot. How to update your code: * Instead of `~EXPR`, you should write `box EXPR`. * Instead of `~TYPE`, you should write `Box<Type>`. * Instead of `~PATTERN`, you should write `box PATTERN`. [breaking-change]
Diffstat (limited to 'src/libstd/clone.rs')
| -rw-r--r-- | src/libstd/clone.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/libstd/clone.rs b/src/libstd/clone.rs index e25f9c5ad4f..36d1cd9ba94 100644 --- a/src/libstd/clone.rs +++ b/src/libstd/clone.rs @@ -21,6 +21,8 @@ the `clone` method. */ +use owned::Box; + /// A common trait for cloning an object. pub trait Clone { /// Returns a copy of the value. The contents of owned pointers @@ -39,14 +41,14 @@ pub trait Clone { } } -impl<T: Clone> Clone for ~T { +impl<T: Clone> Clone for Box<T> { /// Return a copy of the owned box. #[inline] - fn clone(&self) -> ~T { box {(**self).clone()} } + fn clone(&self) -> Box<T> { box {(**self).clone()} } /// Perform copy-assignment from `source` by reusing the existing allocation. #[inline] - fn clone_from(&mut self, source: &~T) { + fn clone_from(&mut self, source: &Box<T>) { (**self).clone_from(&(**source)); } } @@ -127,7 +129,7 @@ extern_fn_clone!(A, B, C, D, E, F, G, H) #[test] fn test_owned_clone() { let a = box 5i; - let b: ~int = a.clone(); + let b: Box<int> = a.clone(); assert_eq!(a, b); } |
