Skip to content

Commit a72fcd5

Browse files
committed
---
yaml --- r: 51970 b: refs/heads/incoming c: d09835d h: refs/heads/master v: v3
1 parent 3b59ec1 commit a72fcd5

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 8eb2bab100b42f0ba751552d8eff00eb2134c55a
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/incoming: 28527ce8a272f117e6dcc25725452ba6430f6694
9+
refs/heads/incoming: d09835d2e3c0cb3227baec0ba6f1b23d7c95f474
1010
refs/heads/dist-snap: 8b98e5a296d95c5e832db0756828e5bec31c6f50
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/libcore/clone.rs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -36,6 +36,16 @@ impl<T:Clone> Clone for ~T {
3636
fn clone(&self) -> ~T { ~(**self).clone() }
3737
}
3838

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+
3949
macro_rules! clone_impl(
4050
($t:ty) => {
4151
impl Clone for $t {
@@ -63,3 +73,24 @@ clone_impl!(f64)
6373

6474
clone_impl!(bool)
6575
clone_impl!(char)
76+
77+
#[test]
78+
fn test_owned_clone() {
79+
let a : ~int = ~5i;
80+
let b : ~int = a.clone();
81+
assert!(a == b);
82+
}
83+
84+
#[test]
85+
fn test_managed_clone() {
86+
let a : @int = @5i;
87+
let b : @int = a.clone();
88+
assert!(a == b);
89+
}
90+
91+
#[test]
92+
fn test_managed_mut_clone() {
93+
let a : @int = @5i;
94+
let b : @int = a.clone();
95+
assert!(a == b);
96+
}

branches/incoming/src/test/run-pass/borrowck-borrow-from-expr-block.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -13,7 +13,7 @@ fn borrow(x: &int, f: &fn(x: &int)) {
1313
}
1414

1515
fn test1(x: @~int) {
16-
do borrow(&*x.clone()) |p| {
16+
do borrow(&**x.clone()) |p| {
1717
let x_a = ptr::addr_of(&(**x));
1818
assert!((x_a as uint) != ptr::to_uint(p));
1919
assert!(unsafe{*x_a} == *p);

0 commit comments

Comments
 (0)