Auto merge of #30130 - tbu-:pr_array_clone, r=alexcrichton

[breaking-change]
This commit is contained in:
bors 2015-12-04 22:52:02 +00:00
commit e22a64e8d8

View File

@ -27,7 +27,7 @@
use fmt;
use hash::{Hash, self};
use iter::IntoIterator;
use marker::{Copy, Sized, Unsize};
use marker::{Sized, Unsize};
use option::Option;
use slice::{Iter, IterMut, SliceExt};
@ -94,13 +94,6 @@ fn borrow_mut(&mut self) -> &mut [T] {
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T:Copy> Clone for [T; $N] {
fn clone(&self) -> [T; $N] {
*self
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Hash> Hash for [T; $N] {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
@ -210,3 +203,30 @@ macro_rules! array_impl_default {
}
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}
macro_rules! array_impl_clone {
{$n:expr, $i:expr, $($idx:expr,)*} => {
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Clone> Clone for [T; $n] {
fn clone(&self) -> [T; $n] {
[self[$i-$i].clone(), $(self[$i-$idx].clone()),*]
}
}
array_impl_clone!{$i, $($idx,)*}
};
{$n:expr,} => {
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Clone> Clone for [T; 0] {
fn clone(&self) -> [T; 0] {
[]
}
}
};
}
array_impl_clone! {
32, 31, 30,
29, 28, 27, 26, 25, 24, 23, 22, 21, 20,
19, 18, 17, 16, 15, 14, 13, 12, 11, 10,
9, 8, 7, 6, 5, 4, 3, 2, 1, 0,
}