Skip to content

Commit 7867de0

Browse files
committed
Implement Clone for arrays without using slice patterns
1 parent 19b9ad7 commit 7867de0

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/libcore/array.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -205,15 +205,15 @@ macro_rules! array_impl_default {
205205
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}
206206

207207
macro_rules! array_impl_clone {
208-
{$n:expr, $t:ident $($ts:ident)*} => {
208+
{$n:expr, $i:expr, $($idx:expr,)*} => {
209209
#[stable(feature = "rust1", since = "1.0.0")]
210210
impl<T: Clone> Clone for [T; $n] {
211211
fn clone(&self) -> [T; $n] {
212-
let &[ref $t, $(ref $ts),*] = self;
213-
[$t.clone(), $($ts.clone()),*]
212+
let temp = [&self[$i], $(&self[$idx]),*];
213+
[temp[$i].clone(), $(temp[$idx].clone()),*]
214214
}
215215
}
216-
array_impl_clone!{($n - 1), $($ts)*}
216+
array_impl_clone!{$i, $($idx,)*}
217217
};
218218
{$n:expr,} => {
219219
#[stable(feature = "rust1", since = "1.0.0")]
@@ -225,9 +225,9 @@ macro_rules! array_impl_clone {
225225
};
226226
}
227227

228-
array_impl_clone! { 32,
229-
t00 t01 t02 t03 t04 t05 t06 t07 t08 t09
230-
t10 t11 t12 t13 t14 t15 t16 t17 t18 t19
231-
t20 t21 t22 t23 t24 t25 t26 t27 t28 t29
232-
t30 t31
228+
array_impl_clone! {
229+
32, 31, 30,
230+
29, 28, 27, 26, 25, 24, 23, 22, 21, 20,
231+
19, 18, 17, 16, 15, 14, 13, 12, 11, 10,
232+
9, 8, 7, 6, 5, 4, 3, 2, 1, 0,
233233
}

src/libcore/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@
8585
#![feature(unwind_attributes)]
8686
#![cfg_attr(stage0, feature(simd))]
8787
#![cfg_attr(not(stage0), feature(repr_simd, platform_intrinsics))]
88-
#![feature(slice_patterns)]
8988
#![feature(staged_api)]
9089
#![feature(unboxed_closures)]
9190

0 commit comments

Comments
 (0)