@@ -60,6 +60,7 @@ use std::mem::ManuallyDrop;
6060use std:: ops;
6161use std:: ptr;
6262use std:: slice;
63+ use std:: slice:: SliceIndex ;
6364#[ cfg( feature = "std" ) ]
6465use std:: io;
6566#[ cfg( feature = "serde" ) ]
@@ -1291,30 +1292,19 @@ impl<A: Array> From<A> for SmallVec<A> {
12911292 }
12921293}
12931294
1294- macro_rules! impl_index {
1295- ( $index_type: ty, $output_type: ty) => {
1296- impl <A : Array > ops:: Index <$index_type> for SmallVec <A > {
1297- type Output = $output_type;
1298- #[ inline]
1299- fn index( & self , index: $index_type) -> & $output_type {
1300- & ( & * * self ) [ index]
1301- }
1302- }
1295+ impl < A : Array , T : SliceIndex < [ A :: Item ] > > ops:: Index < T > for SmallVec < A > {
1296+ type Output = T :: Output ;
13031297
1304- impl <A : Array > ops:: IndexMut <$index_type> for SmallVec <A > {
1305- #[ inline]
1306- fn index_mut( & mut self , index: $index_type) -> & mut $output_type {
1307- & mut ( & mut * * self ) [ index]
1308- }
1309- }
1298+ fn index ( & self , index : T ) -> & T :: Output {
1299+ & ( * * self ) [ index]
13101300 }
13111301}
13121302
1313- impl_index ! ( usize , A :: Item ) ;
1314- impl_index ! ( ops :: Range < usize > , [ A :: Item ] ) ;
1315- impl_index ! ( ops :: RangeFrom < usize > , [ A :: Item ] ) ;
1316- impl_index ! ( ops :: RangeTo < usize > , [ A :: Item ] ) ;
1317- impl_index ! ( ops :: RangeFull , [ A :: Item ] ) ;
1303+ impl < A : Array , T : SliceIndex < [ A :: Item ] > > ops :: IndexMut < T > for SmallVec < A > {
1304+ fn index_mut ( & mut self , index : T ) -> & mut T :: Output {
1305+ & mut ( & mut * * self ) [ index ]
1306+ }
1307+ }
13181308
13191309impl < A : Array > ExtendFromSlice < A :: Item > for SmallVec < A > where A :: Item : Copy {
13201310 fn extend_from_slice ( & mut self , other : & [ A :: Item ] ) {
0 commit comments