File tree 1 file changed +13
-3
lines changed
1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -369,7 +369,14 @@ fn opt_vals(mm: &Matches, nm: &str) -> ~[Optval] {
369
369
} ;
370
370
}
371
371
372
- fn opt_val( mm: & Matches , nm: & str ) -> Optval { opt_vals ( mm, nm) [ 0 ] . clone ( ) }
372
+ fn opt_val( mm: & Matches , nm: & str ) -> Option <Optval > {
373
+ let vals = opt_vals ( mm, nm) ;
374
+ if ( vals. is_empty ( ) ) {
375
+ None
376
+ } else {
377
+ Some ( opt_vals ( mm, nm) [ 0 ] . clone ( ) )
378
+ }
379
+ }
373
380
374
381
/// Returns true if an option was matched
375
382
pub fn opt_present ( mm : & Matches , nm : & str ) -> bool {
@@ -400,7 +407,10 @@ pub fn opts_present(mm: &Matches, names: &[~str]) -> bool {
400
407
* argument
401
408
*/
402
409
pub fn opt_str ( mm : & Matches , nm : & str ) -> ~str {
403
- return match opt_val ( mm, nm) { Val ( s) => s, _ => fail ! ( ) } ;
410
+ return match opt_val ( mm, nm) {
411
+ Some ( Val ( s) ) => s,
412
+ _ => fail ! ( )
413
+ } ;
404
414
}
405
415
406
416
/**
@@ -412,7 +422,7 @@ pub fn opt_str(mm: &Matches, nm: &str) -> ~str {
412
422
pub fn opts_str( mm : & Matches , names : & [ ~str ] ) -> ~str {
413
423
for names. iter( ) . advance |nm| {
414
424
match opt_val( mm, * nm) {
415
- Val ( ref s) => return ( * s) . clone( ) ,
425
+ Some ( Val ( ref s) ) => return ( * s) . clone( ) ,
416
426
_ => ( )
417
427
}
418
428
}
You can’t perform that action at this time.
0 commit comments