File tree Expand file tree Collapse file tree 3 files changed +35
-4
lines changed Expand file tree Collapse file tree 3 files changed +35
-4
lines changed Original file line number Diff line number Diff line change 1
1
---
2
2
refs/heads/master: 5f13e9ccc2e3328d4cd8ca49f84e6840dd998346
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
- refs/heads/snap-stage3: 28527ce8a272f117e6dcc25725452ba6430f6694
4
+ refs/heads/snap-stage3: d09835d2e3c0cb3227baec0ba6f1b23d7c95f474
5
5
refs/heads/try: 8eb2bab100b42f0ba751552d8eff00eb2134c55a
6
6
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
7
7
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
Original file line number Diff line number Diff line change 1
- // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1
+ // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
2
2
// file at the top-level directory of this distribution and at
3
3
// http://rust-lang.org/COPYRIGHT.
4
4
//
@@ -36,6 +36,16 @@ impl<T:Clone> Clone for ~T {
36
36
fn clone ( & self ) -> ~T { ~( * * self ) . clone ( ) }
37
37
}
38
38
39
+ impl < T : Clone > Clone for @T {
40
+ #[ inline( always) ]
41
+ fn clone ( & self ) -> @T { @( * * self ) . clone ( ) }
42
+ }
43
+
44
+ impl < T : Clone > Clone for @mut T {
45
+ #[ inline( always) ]
46
+ fn clone ( & self ) -> @mut T { @mut ( * * self ) . clone ( ) }
47
+ }
48
+
39
49
macro_rules! clone_impl(
40
50
( $t: ty) => {
41
51
impl Clone for $t {
@@ -63,3 +73,24 @@ clone_impl!(f64)
63
73
64
74
clone_impl ! ( bool )
65
75
clone_impl ! ( char )
76
+
77
+ #[ test]
78
+ fn test_owned_clone ( ) {
79
+ let a : ~int = ~5 i;
80
+ let b : ~int = a. clone ( ) ;
81
+ assert ! ( a == b) ;
82
+ }
83
+
84
+ #[ test]
85
+ fn test_managed_clone ( ) {
86
+ let a : @int = @5 i;
87
+ let b : @int = a. clone ( ) ;
88
+ assert ! ( a == b) ;
89
+ }
90
+
91
+ #[ test]
92
+ fn test_managed_mut_clone ( ) {
93
+ let a : @int = @5 i;
94
+ let b : @int = a. clone ( ) ;
95
+ assert ! ( a == b) ;
96
+ }
Original file line number Diff line number Diff line change 1
- // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1
+ // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
2
2
// file at the top-level directory of this distribution and at
3
3
// http://rust-lang.org/COPYRIGHT.
4
4
//
@@ -13,7 +13,7 @@ fn borrow(x: &int, f: &fn(x: &int)) {
13
13
}
14
14
15
15
fn test1 ( x : @~int ) {
16
- do borrow ( & * x. clone ( ) ) |p| {
16
+ do borrow ( & * * x. clone ( ) ) |p| {
17
17
let x_a = ptr:: addr_of ( & ( * * x) ) ;
18
18
assert ! ( ( x_a as uint) != ptr:: to_uint( p) ) ;
19
19
assert ! ( unsafe { * x_a} == * p) ;
You can’t perform that action at this time.
0 commit comments