@@ -145,7 +145,7 @@ pub struct PackageDependency {
145
145
pub kind : DepKind ,
146
146
}
147
147
148
- #[ derive( Debug , Clone , Eq , PartialEq , PartialOrd , Ord ) ]
148
+ #[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
149
149
pub enum DepKind {
150
150
/// Available to the library, binary, and dev targets in the package (but not the build script).
151
151
Normal ,
@@ -156,23 +156,20 @@ pub enum DepKind {
156
156
}
157
157
158
158
impl DepKind {
159
- fn iter ( list : & [ cargo_metadata:: DepKindInfo ] ) -> impl Iterator < Item = Self > + ' _ {
160
- let mut dep_kinds = Vec :: new ( ) ;
159
+ fn iter ( list : & [ cargo_metadata:: DepKindInfo ] ) -> impl Iterator < Item = Self > {
160
+ let mut dep_kinds = [ None ; 3 ] ;
161
161
if list. is_empty ( ) {
162
- dep_kinds. push ( Self :: Normal ) ;
162
+ dep_kinds[ 0 ] = Some ( Self :: Normal ) ;
163
163
}
164
164
for info in list {
165
- let kind = match info. kind {
166
- cargo_metadata:: DependencyKind :: Normal => Self :: Normal ,
167
- cargo_metadata:: DependencyKind :: Development => Self :: Dev ,
168
- cargo_metadata:: DependencyKind :: Build => Self :: Build ,
165
+ match info. kind {
166
+ cargo_metadata:: DependencyKind :: Normal => dep_kinds [ 0 ] = Some ( Self :: Normal ) ,
167
+ cargo_metadata:: DependencyKind :: Development => dep_kinds [ 1 ] = Some ( Self :: Dev ) ,
168
+ cargo_metadata:: DependencyKind :: Build => dep_kinds [ 2 ] = Some ( Self :: Build ) ,
169
169
cargo_metadata:: DependencyKind :: Unknown => continue ,
170
- } ;
171
- dep_kinds. push ( kind) ;
170
+ }
172
171
}
173
- dep_kinds. sort_unstable ( ) ;
174
- dep_kinds. dedup ( ) ;
175
- dep_kinds. into_iter ( )
172
+ dep_kinds. into_iter ( ) . flatten ( )
176
173
}
177
174
}
178
175
0 commit comments