@@ -12,6 +12,7 @@ use crate::convert::{Infallible, TryFrom};
12
12
use crate :: fmt;
13
13
use crate :: hash:: { self , Hash } ;
14
14
use crate :: marker:: Unsize ;
15
+ use crate :: ops:: { Index , IndexMut } ;
15
16
use crate :: slice:: { Iter , IterMut } ;
16
17
17
18
mod iter;
@@ -208,6 +209,30 @@ impl<'a, T, const N: usize> IntoIterator for &'a mut [T; N] {
208
209
}
209
210
}
210
211
212
+ #[ stable( feature = "index_trait_on_arrays" , since = "1.50.0" ) ]
213
+ impl < T , I , const N : usize > Index < I > for [ T ; N ]
214
+ where
215
+ [ T ] : Index < I > ,
216
+ {
217
+ type Output = <[ T ] as Index < I > >:: Output ;
218
+
219
+ #[ inline]
220
+ fn index ( & self , index : I ) -> & Self :: Output {
221
+ Index :: index ( self as & [ T ] , index)
222
+ }
223
+ }
224
+
225
+ #[ stable( feature = "index_trait_on_arrays" , since = "1.50.0" ) ]
226
+ impl < T , I , const N : usize > IndexMut < I > for [ T ; N ]
227
+ where
228
+ [ T ] : IndexMut < I > ,
229
+ {
230
+ #[ inline]
231
+ fn index_mut ( & mut self , index : I ) -> & mut Self :: Output {
232
+ IndexMut :: index_mut ( self as & mut [ T ] , index)
233
+ }
234
+ }
235
+
211
236
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
212
237
impl < A , B , const N : usize > PartialEq < [ B ; N ] > for [ A ; N ]
213
238
where
0 commit comments