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.
2 parents 7bef1ff + 22c3db5 commit 92a1f6dCopy full SHA for 92a1f6d
src/libcore/clone.rs
@@ -48,6 +48,12 @@ impl<T> Clone for @mut T {
48
fn clone(&self) -> @mut T { *self }
49
}
50
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
+
57
macro_rules! clone_impl(
58
($t:ty) => {
59
impl Clone for $t {
@@ -166,3 +172,11 @@ fn test_managed_mut_clone() {
166
172
*b = 10;
167
173
assert!(a == b);
168
174
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