We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4e82610 commit 22c3db5Copy full SHA for 22c3db5
src/libcore/clone.rs
@@ -51,6 +51,12 @@ impl<T> Clone for @mut T {
51
fn clone(&self) -> @mut T { *self }
52
}
53
54
+impl<'self, T> Clone for &'self T {
55
+ /// Return a shallow copy of the borrowed pointer.
56
+ #[inline(always)]
57
+ fn clone(&self) -> &'self T { *self }
58
+}
59
+
60
macro_rules! clone_impl(
61
($t:ty) => {
62
impl Clone for $t {
@@ -102,3 +108,11 @@ fn test_managed_mut_clone() {
102
108
*b = 10;
103
109
assert!(a == b);
104
110
111
112
+#[test]
113
+fn test_borrowed_clone() {
114
+ let x = 5i;
115
+ let y: &int = &x;
116
+ let z: &int = (&y).clone();
117
+ assert_eq!(*z, 5);
118
0 commit comments