about summary refs log tree commit diff
path: root/src/libcore/array.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-09-04 20:23:51 +0000
committerbors <bors@rust-lang.org>2015-09-04 20:23:51 +0000
commit1110f1e873e9c082333b8239422e482b66d6645f (patch)
tree13e7546c10607ec47bc4b9a32fea80c04004b9f1 /src/libcore/array.rs
parent668dac477eeb8b7d7bf0556c77bbc3292e5c7cc2 (diff)
parent52417d5b5c4298548d42528a2c0909bc82bacc95 (diff)
downloadrust-1110f1e873e9c082333b8239422e482b66d6645f.tar.gz
rust-1110f1e873e9c082333b8239422e482b66d6645f.zip
Auto merge of #28197 - petrochenkov:borrow, r=alexcrichton
Diffstat (limited to 'src/libcore/array.rs')
-rw-r--r--src/libcore/array.rs15
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] {