@@ -12,6 +12,7 @@ use crate::convert::{Infallible, TryFrom};
1212use crate :: fmt;
1313use crate :: hash:: { self , Hash } ;
1414use crate :: marker:: Unsize ;
15+ use crate :: ops:: { Index , IndexMut } ;
1516use crate :: slice:: { Iter , IterMut } ;
1617
1718mod iter;
@@ -208,6 +209,30 @@ impl<'a, T, const N: usize> IntoIterator for &'a mut [T; N] {
208209 }
209210}
210211
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+
211236#[ stable( feature = "rust1" , since = "1.0.0" ) ]
212237impl < A , B , const N : usize > PartialEq < [ B ; N ] > for [ A ; N ]
213238where
0 commit comments