@@ -181,6 +181,7 @@ mod impl_ {
181
181
use std:: fs:: File ;
182
182
use std:: io:: Read ;
183
183
use std:: mem;
184
+ use std:: iter;
184
185
use std:: path:: { Path , PathBuf } ;
185
186
186
187
use Tool ;
@@ -217,28 +218,35 @@ mod impl_ {
217
218
}
218
219
}
219
220
220
- fn vs16_instance ( ) -> Option < PathBuf > {
221
- vs15_instances ( ) ?. find_map ( |instance| {
221
+ fn vs16_instances ( ) -> Box < Iterator < Item =PathBuf > > {
222
+ let instances = if let Some ( instances) = vs15_instances ( ) {
223
+ instances
224
+ } else {
225
+ return Box :: new ( iter:: empty ( ) ) ;
226
+ } ;
227
+ Box :: new ( instances. filter_map ( |instance| {
222
228
let instance = instance. ok ( ) ?;
223
- let installation_name = instance. installation_name ( ) . ok ( ) ?; ;
229
+ let installation_name = instance. installation_name ( ) . ok ( ) ?;
224
230
if installation_name. to_str ( ) ?. starts_with ( "VisualStudio/16." ) {
225
231
Some ( PathBuf :: from ( instance. installation_path ( ) . ok ( ) ?) )
226
232
} else {
227
233
None
228
234
}
229
- } )
235
+ } ) )
230
236
}
231
237
232
238
fn find_tool_in_vs16_path ( tool : & str , target : & str ) -> Option < Tool > {
233
- let path = vs16_instance ( ) ?. join ( tool) ;
234
- if !path. is_file ( ) {
235
- return None ;
236
- }
237
- let mut tool = Tool :: new ( path) ;
238
- if target. contains ( "x86_64" ) {
239
- tool. env . push ( ( "Platform" . into ( ) , "X64" . into ( ) ) ) ;
240
- }
241
- Some ( tool)
239
+ vs16_instances ( ) . find_map ( |path| {
240
+ let path = path. join ( tool) ;
241
+ if !path. is_file ( ) {
242
+ return None ;
243
+ }
244
+ let mut tool = Tool :: new ( path) ;
245
+ if target. contains ( "x86_64" ) {
246
+ tool. env . push ( ( "Platform" . into ( ) , "X64" . into ( ) ) ) ;
247
+ }
248
+ Some ( tool)
249
+ } )
242
250
}
243
251
244
252
fn find_msbuild_vs16 ( target : & str ) -> Option < Tool > {
0 commit comments