@@ -293,35 +293,30 @@ fn build_options<O: Default>(
293293 None => ( option, None ) ,
294294 Some ( ( k, v) ) => ( k. to_string ( ) , Some ( v) ) ,
295295 } ;
296+
296297 let option_to_lookup = key. replace ( "-" , "_" ) ;
297- let mut found = false ;
298- for & ( candidate, setter, type_desc, _) in descrs {
299- if option_to_lookup != candidate {
300- continue ;
301- }
302- if !setter ( & mut op, value) {
303- match value {
304- None => early_error (
305- error_format,
306- & format ! (
307- "{0} option `{1}` requires {2} ({3} {1}=<value>)" ,
308- outputname, key, type_desc, prefix
298+ match descrs. iter ( ) . find ( |( name, ..) | * name == option_to_lookup) {
299+ Some ( ( _, setter, type_desc, _) ) => {
300+ if !setter ( & mut op, value) {
301+ match value {
302+ None => early_error (
303+ error_format,
304+ & format ! (
305+ "{0} option `{1}` requires {2} ({3} {1}=<value>)" ,
306+ outputname, key, type_desc, prefix
307+ ) ,
309308 ) ,
310- ) ,
311- Some ( value ) => early_error (
312- error_format ,
313- & format ! (
314- "incorrect value `{}` for {} option `{}` - {} was expected" ,
315- value , outputname , key , type_desc
309+ Some ( value ) => early_error (
310+ error_format ,
311+ & format ! (
312+ "incorrect value `{}` for {} option `{}` - {} was expected" ,
313+ value , outputname , key , type_desc
314+ ) ,
316315 ) ,
317- ) ,
316+ }
318317 }
319318 }
320- found = true ;
321- break ;
322- }
323- if !found {
324- early_error ( error_format, & format ! ( "unknown {} option: `{}`" , outputname, key) ) ;
319+ None => early_error ( error_format, & format ! ( "unknown {} option: `{}`" , outputname, key) ) ,
325320 }
326321 }
327322 return op;
0 commit comments