diff --git a/src/libcore/array.rs b/src/libcore/array.rs index b2c23f051d5..91301ee558c 100644 --- a/src/libcore/array.rs +++ b/src/libcore/array.rs @@ -18,6 +18,7 @@ use clone::Clone; use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering}; +use convert::{AsRef, AsMut}; use fmt; use hash::{Hash, self}; use iter::IntoIterator; @@ -53,6 +54,24 @@ macro_rules! array_impls { } } + #[unstable(feature = "array_as_ref", + reason = "should ideally be implemented for all fixed-sized arrays")] + impl AsRef<[T]> for [T; $N] { + #[inline] + fn as_ref(&self) -> &[T] { + &self[..] + } + } + + #[unstable(feature = "array_as_ref", + reason = "should ideally be implemented for all fixed-sized arrays")] + impl AsMut<[T]> for [T; $N] { + #[inline] + fn as_mut(&mut self) -> &mut [T] { + &mut self[..] + } + } + #[stable(feature = "rust1", since = "1.0.0")] impl Clone for [T; $N] { fn clone(&self) -> [T; $N] {