diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2015-09-03 19:35:26 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2015-09-03 19:35:26 +0300 |
| commit | 52417d5b5c4298548d42528a2c0909bc82bacc95 (patch) | |
| tree | e684d9b00a80fd5130df1ce5230c4e08d55a1370 /src/libcore/array.rs | |
| parent | 9e9c83b8994fab4f69fc75838c8c856b57caa5d1 (diff) | |
| download | rust-52417d5b5c4298548d42528a2c0909bc82bacc95.tar.gz rust-52417d5b5c4298548d42528a2c0909bc82bacc95.zip | |
Implement `Borrow` for fixed-size arrays
Diffstat (limited to 'src/libcore/array.rs')
| -rw-r--r-- | src/libcore/array.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libcore/array.rs b/src/libcore/array.rs index 0959029b953..8c785b10923 100644 --- a/src/libcore/array.rs +++ b/src/libcore/array.rs @@ -19,6 +19,7 @@ integer constants", issue = "27778")] +use borrow::{Borrow, BorrowMut}; use clone::Clone; use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering}; use convert::{AsRef, AsMut}; @@ -70,6 +71,20 @@ macro_rules! array_impls { } } + #[stable(feature = "array_borrow", since = "1.4.0")] + impl<T> Borrow<[T]> for [T; $N] { + fn borrow(&self) -> &[T] { + self + } + } + + #[stable(feature = "array_borrow", since = "1.4.0")] + impl<T> BorrowMut<[T]> for [T; $N] { + fn borrow_mut(&mut self) -> &mut [T] { + self + } + } + #[stable(feature = "rust1", since = "1.0.0")] impl<T:Copy> Clone for [T; $N] { fn clone(&self) -> [T; $N] { |
