@@ -1717,22 +1717,21 @@ where
17171717{
17181718 match * substructure. fields {
17191719 EnumMatching ( .., ref all_fields) | Struct ( _, ref all_fields) => {
1720- let ( base, all_fields ) = match ( all_fields. is_empty ( ) , use_foldl) {
1720+ let ( base, rest ) = match ( all_fields. is_empty ( ) , use_foldl) {
17211721 ( false , true ) => {
1722- let field = & all_fields[ 0 ] ;
1723- let args = ( field . span , field . self_ . clone ( ) , & field . other [ ..] ) ;
1724- ( b ( cx, Some ( args) ) , & all_fields [ 1 .. ] )
1722+ let ( first , rest ) = all_fields. split_first ( ) . unwrap ( ) ;
1723+ let args = ( first . span , first . self_ . clone ( ) , & first . other [ ..] ) ;
1724+ ( b ( cx, Some ( args) ) , rest )
17251725 }
17261726 ( false , false ) => {
1727- let idx = all_fields. len ( ) - 1 ;
1728- let field = & all_fields[ idx] ;
1729- let args = ( field. span , field. self_ . clone ( ) , & field. other [ ..] ) ;
1730- ( b ( cx, Some ( args) ) , & all_fields[ ..idx] )
1727+ let ( last, rest) = all_fields. split_last ( ) . unwrap ( ) ;
1728+ let args = ( last. span , last. self_ . clone ( ) , & last. other [ ..] ) ;
1729+ ( b ( cx, Some ( args) ) , rest)
17311730 }
17321731 ( true , _) => ( b ( cx, None ) , & all_fields[ ..] ) ,
17331732 } ;
17341733
1735- cs_fold_fields ( use_foldl, f, base, cx, all_fields )
1734+ cs_fold_fields ( use_foldl, f, base, cx, rest )
17361735 }
17371736 EnumNonMatchingCollapsed ( ..) => {
17381737 cs_fold_enumnonmatch ( enum_nonmatch_f, cx, trait_span, substructure)
0 commit comments