Skip to content

Commit 5e8ffe5

Browse files
committed
---
yaml --- r: 61394 b: refs/heads/try c: 92a1f6d h: refs/heads/master v: v3
1 parent eb09e00 commit 5e8ffe5

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2d28d645422c1617be58c8ca7ad9a457264ca850
5-
refs/heads/try: 7bef1ff4b19805f6b452697ad5febd4965cfaea3
5+
refs/heads/try: 92a1f6de97c8360c77763d4e6ef9fc6b6775cfc0
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libcore/clone.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ impl<T> Clone for @mut T {
4848
fn clone(&self) -> @mut T { *self }
4949
}
5050

51+
impl<'self, T> Clone for &'self T {
52+
/// Return a shallow copy of the borrowed pointer.
53+
#[inline(always)]
54+
fn clone(&self) -> &'self T { *self }
55+
}
56+
5157
macro_rules! clone_impl(
5258
($t:ty) => {
5359
impl Clone for $t {
@@ -166,3 +172,11 @@ fn test_managed_mut_clone() {
166172
*b = 10;
167173
assert!(a == b);
168174
}
175+
176+
#[test]
177+
fn test_borrowed_clone() {
178+
let x = 5i;
179+
let y: &int = &x;
180+
let z: &int = (&y).clone();
181+
assert_eq!(*z, 5);
182+
}

0 commit comments

Comments
 (0)