@@ -1717,22 +1717,21 @@ where
1717
1717
{
1718
1718
match * substructure. fields {
1719
1719
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) {
1721
1721
( 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 )
1725
1725
}
1726
1726
( 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)
1731
1730
}
1732
1731
( true , _) => ( b ( cx, None ) , & all_fields[ ..] ) ,
1733
1732
} ;
1734
1733
1735
- cs_fold_fields ( use_foldl, f, base, cx, all_fields )
1734
+ cs_fold_fields ( use_foldl, f, base, cx, rest )
1736
1735
}
1737
1736
EnumNonMatchingCollapsed ( ..) => {
1738
1737
cs_fold_enumnonmatch ( enum_nonmatch_f, cx, trait_span, substructure)
0 commit comments