diff options
| author | Tobias Bucher <tobiasbucher5991@gmail.com> | 2014-11-14 12:37:59 +0100 |
|---|---|---|
| committer | Tobias Bucher <tobiasbucher5991@gmail.com> | 2014-11-14 12:37:59 +0100 |
| commit | eb9684ee19e1d79999b9809704fbffe072332e7b (patch) | |
| tree | a1d032702a55cdb826af494d8562f0e3b8fe9c47 /src/libcore/array.rs | |
| parent | bb2168c5252adeda1dd35ccf7050df89655233d7 (diff) | |
| download | rust-eb9684ee19e1d79999b9809704fbffe072332e7b.tar.gz rust-eb9684ee19e1d79999b9809704fbffe072332e7b.zip | |
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.
Diffstat (limited to 'src/libcore/array.rs')
| -rw-r--r-- | src/libcore/array.rs | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/src/libcore/array.rs b/src/libcore/array.rs index 829605ce7cc..60765e82cb4 100644 --- a/src/libcore/array.rs +++ b/src/libcore/array.rs @@ -8,22 +8,36 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -/*! - * Implementations of things like `Eq` for fixed-length arrays - * up to a certain length. Eventually we should able to generalize - * to all lengths. - */ +//! Implementations of things like `Eq` for fixed-length arrays +//! up to a certain length. Eventually we should able to generalize +//! to all lengths. -#![stable] #![experimental] // not yet reviewed -use cmp::*; -use option::{Option}; +use clone::Clone; +use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering}; +use fmt; +use kinds::Copy; +use option::Option; // macro for implementing n-ary tuple functions and operations macro_rules! array_impls { ($($N:expr)+) => { $( + #[unstable = "waiting for Clone to stabilize"] + impl<T:Copy> Clone for [T, ..$N] { + fn clone(&self) -> [T, ..$N] { + *self + } + } + + #[unstable = "waiting for Show to stabilize"] + impl<T:fmt::Show> fmt::Show for [T, ..$N] { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Show::fmt(&self[], f) + } + } + #[unstable = "waiting for PartialEq to stabilize"] impl<T:PartialEq> PartialEq for [T, ..$N] { #[inline] |
