@@ -60,6 +60,7 @@ use std::mem::ManuallyDrop;
60
60
use std:: ops;
61
61
use std:: ptr;
62
62
use std:: slice;
63
+ use std:: slice:: SliceIndex ;
63
64
#[ cfg( feature = "std" ) ]
64
65
use std:: io;
65
66
#[ cfg( feature = "serde" ) ]
@@ -1291,30 +1292,19 @@ impl<A: Array> From<A> for SmallVec<A> {
1291
1292
}
1292
1293
}
1293
1294
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 ;
1303
1297
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]
1310
1300
}
1311
1301
}
1312
1302
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
+ }
1318
1308
1319
1309
impl < A : Array > ExtendFromSlice < A :: Item > for SmallVec < A > where A :: Item : Copy {
1320
1310
fn extend_from_slice ( & mut self , other : & [ A :: Item ] ) {
0 commit comments