Skip to content

Commit eb9684e

Browse files
committed
Add Show and Clone trait to arrays
Due to not being able to parametrize over array sizes, `Clone` is only implemented for element types that are `Copy`able.
1 parent bb2168c commit eb9684e

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

src/libcore/array.rs

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,36 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
/*!
12-
* Implementations of things like `Eq` for fixed-length arrays
13-
* up to a certain length. Eventually we should able to generalize
14-
* to all lengths.
15-
*/
11+
//! Implementations of things like `Eq` for fixed-length arrays
12+
//! up to a certain length. Eventually we should able to generalize
13+
//! to all lengths.
1614
17-
#![stable]
1815
#![experimental] // not yet reviewed
1916

20-
use cmp::*;
21-
use option::{Option};
17+
use clone::Clone;
18+
use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering};
19+
use fmt;
20+
use kinds::Copy;
21+
use option::Option;
2222

2323
// macro for implementing n-ary tuple functions and operations
2424
macro_rules! array_impls {
2525
($($N:expr)+) => {
2626
$(
27+
#[unstable = "waiting for Clone to stabilize"]
28+
impl<T:Copy> Clone for [T, ..$N] {
29+
fn clone(&self) -> [T, ..$N] {
30+
*self
31+
}
32+
}
33+
34+
#[unstable = "waiting for Show to stabilize"]
35+
impl<T:fmt::Show> fmt::Show for [T, ..$N] {
36+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
37+
fmt::Show::fmt(&self[], f)
38+
}
39+
}
40+
2741
#[unstable = "waiting for PartialEq to stabilize"]
2842
impl<T:PartialEq> PartialEq for [T, ..$N] {
2943
#[inline]

0 commit comments

Comments
 (0)