Skip to content

Commit e22a64e

Browse files
committed
Auto merge of #30130 - tbu-:pr_array_clone, r=alexcrichton
[breaking-change]
2 parents 55a4e05 + 6dff9d0 commit e22a64e

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

src/libcore/array.rs

+28-8
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use default::Default;
2727
use fmt;
2828
use hash::{Hash, self};
2929
use iter::IntoIterator;
30-
use marker::{Copy, Sized, Unsize};
30+
use marker::{Sized, Unsize};
3131
use option::Option;
3232
use slice::{Iter, IterMut, SliceExt};
3333

@@ -94,13 +94,6 @@ macro_rules! array_impls {
9494
}
9595
}
9696

97-
#[stable(feature = "rust1", since = "1.0.0")]
98-
impl<T:Copy> Clone for [T; $N] {
99-
fn clone(&self) -> [T; $N] {
100-
*self
101-
}
102-
}
103-
10497
#[stable(feature = "rust1", since = "1.0.0")]
10598
impl<T: Hash> Hash for [T; $N] {
10699
fn hash<H: hash::Hasher>(&self, state: &mut H) {
@@ -210,3 +203,30 @@ macro_rules! array_impl_default {
210203
}
211204

212205
array_impl_default!{32, T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T}
206+
207+
macro_rules! array_impl_clone {
208+
{$n:expr, $i:expr, $($idx:expr,)*} => {
209+
#[stable(feature = "rust1", since = "1.0.0")]
210+
impl<T: Clone> Clone for [T; $n] {
211+
fn clone(&self) -> [T; $n] {
212+
[self[$i-$i].clone(), $(self[$i-$idx].clone()),*]
213+
}
214+
}
215+
array_impl_clone!{$i, $($idx,)*}
216+
};
217+
{$n:expr,} => {
218+
#[stable(feature = "rust1", since = "1.0.0")]
219+
impl<T: Clone> Clone for [T; 0] {
220+
fn clone(&self) -> [T; 0] {
221+
[]
222+
}
223+
}
224+
};
225+
}
226+
227+
array_impl_clone! {
228+
32, 31, 30,
229+
29, 28, 27, 26, 25, 24, 23, 22, 21, 20,
230+
19, 18, 17, 16, 15, 14, 13, 12, 11, 10,
231+
9, 8, 7, 6, 5, 4, 3, 2, 1, 0,
232+
}

0 commit comments

Comments
 (0)