@@ -13,40 +13,37 @@ pub fn split_features(
1313
1414 // First, we partition the features into two groups: those that use the new
1515 // features syntax (`features2`) and those that don't (`features`).
16- let ( mut features, mut features2) =
17- features
18- . into_iter ( )
19- . partition :: < FeaturesMap , _ > ( |( _k, vals) | {
20- !vals
21- . iter ( )
22- . any ( |v| v. starts_with ( "dep:" ) || v. contains ( "?/" ) )
23- } ) ;
16+ let ( mut features, mut features2) : ( FeaturesMap , FeaturesMap ) = features
17+ . into_iter ( )
18+ . partition ( |( _k, vals) | !vals. iter ( ) . map ( String :: as_ref) . any ( has_features2_syntax) ) ;
2419
2520 // Then, we recursively move features from `features` to `features2` if they
2621 // depend on features in `features2`.
2722 for i in ( 0 ..ITERATION_LIMIT ) . rev ( ) {
2823 let split = features
2924 . into_iter ( )
30- . partition :: < FeaturesMap , _ > ( |( _k, vals) | {
31- !vals. iter ( ) . any ( |v| features2. contains_key ( v) )
32- } ) ;
25+ . partition ( |( _k, vals) | !vals. iter ( ) . any ( |v| features2. contains_key ( v) ) ) ;
3326
3427 features = split. 0 ;
3528
36- if !split. 1 . is_empty ( ) {
37- features2. extend ( split. 1 ) ;
38-
39- if i == 0 {
40- warn ! ( "Iteration limit reached while splitting features!" ) ;
41- }
42- } else {
29+ if split. 1 . is_empty ( ) {
4330 break ;
4431 }
32+
33+ features2. extend ( split. 1 ) ;
34+
35+ if i == 0 {
36+ warn ! ( "Iteration limit reached while splitting features!" ) ;
37+ }
4538 }
4639
4740 ( features, features2)
4841}
4942
43+ fn has_features2_syntax ( s : & str ) -> bool {
44+ s. starts_with ( "dep:" ) || s. contains ( "?/" )
45+ }
46+
5047#[ cfg( test) ]
5148mod tests {
5249 use super :: * ;
0 commit comments