@@ -229,14 +229,14 @@ impl Name {
229
229
if nm. len ( ) == 1 {
230
230
Short ( nm. char_at ( 0 ) )
231
231
} else {
232
- Long ( nm. to_owned ( ) )
232
+ Long ( nm. to_string ( ) )
233
233
}
234
234
}
235
235
236
236
fn to_string ( & self ) -> String {
237
237
match * self {
238
238
Short ( ch) => ch. to_string ( ) ,
239
- Long ( ref s) => s. to_owned ( )
239
+ Long ( ref s) => s. to_string ( )
240
240
}
241
241
}
242
242
}
@@ -375,7 +375,7 @@ impl Matches {
375
375
} else {
376
376
match vals[ 0 ] {
377
377
Val ( ref s) => Some ( ( * s) . clone ( ) ) ,
378
- _ => Some ( def. to_owned ( ) )
378
+ _ => Some ( def. to_string ( ) )
379
379
}
380
380
}
381
381
}
@@ -414,10 +414,10 @@ pub fn reqopt(short_name: &str, long_name: &str, desc: &str, hint: &str) -> OptG
414
414
let len = short_name. len ( ) ;
415
415
assert ! ( len == 1 || len == 0 ) ;
416
416
OptGroup {
417
- short_name : short_name. to_owned ( ) ,
418
- long_name : long_name. to_owned ( ) ,
419
- hint : hint. to_owned ( ) ,
420
- desc : desc. to_owned ( ) ,
417
+ short_name : short_name. to_string ( ) ,
418
+ long_name : long_name. to_string ( ) ,
419
+ hint : hint. to_string ( ) ,
420
+ desc : desc. to_string ( ) ,
421
421
hasarg : Yes ,
422
422
occur : Req
423
423
}
@@ -434,10 +434,10 @@ pub fn optopt(short_name: &str, long_name: &str, desc: &str, hint: &str) -> OptG
434
434
let len = short_name. len ( ) ;
435
435
assert ! ( len == 1 || len == 0 ) ;
436
436
OptGroup {
437
- short_name : short_name. to_owned ( ) ,
438
- long_name : long_name. to_owned ( ) ,
439
- hint : hint. to_owned ( ) ,
440
- desc : desc. to_owned ( ) ,
437
+ short_name : short_name. to_string ( ) ,
438
+ long_name : long_name. to_string ( ) ,
439
+ hint : hint. to_string ( ) ,
440
+ desc : desc. to_string ( ) ,
441
441
hasarg : Yes ,
442
442
occur : Optional
443
443
}
@@ -452,10 +452,10 @@ pub fn optflag(short_name: &str, long_name: &str, desc: &str) -> OptGroup {
452
452
let len = short_name. len ( ) ;
453
453
assert ! ( len == 1 || len == 0 ) ;
454
454
OptGroup {
455
- short_name : short_name. to_owned ( ) ,
456
- long_name : long_name. to_owned ( ) ,
457
- hint : "" . to_owned ( ) ,
458
- desc : desc. to_owned ( ) ,
455
+ short_name : short_name. to_string ( ) ,
456
+ long_name : long_name. to_string ( ) ,
457
+ hint : "" . to_string ( ) ,
458
+ desc : desc. to_string ( ) ,
459
459
hasarg : No ,
460
460
occur : Optional
461
461
}
@@ -471,10 +471,10 @@ pub fn optflagmulti(short_name: &str, long_name: &str, desc: &str) -> OptGroup {
471
471
let len = short_name. len ( ) ;
472
472
assert ! ( len == 1 || len == 0 ) ;
473
473
OptGroup {
474
- short_name : short_name. to_owned ( ) ,
475
- long_name : long_name. to_owned ( ) ,
476
- hint : "" . to_owned ( ) ,
477
- desc : desc. to_owned ( ) ,
474
+ short_name : short_name. to_string ( ) ,
475
+ long_name : long_name. to_string ( ) ,
476
+ hint : "" . to_string ( ) ,
477
+ desc : desc. to_string ( ) ,
478
478
hasarg : No ,
479
479
occur : Multi
480
480
}
@@ -491,10 +491,10 @@ pub fn optflagopt(short_name: &str, long_name: &str, desc: &str, hint: &str) ->
491
491
let len = short_name. len ( ) ;
492
492
assert ! ( len == 1 || len == 0 ) ;
493
493
OptGroup {
494
- short_name : short_name. to_owned ( ) ,
495
- long_name : long_name. to_owned ( ) ,
496
- hint : hint. to_owned ( ) ,
497
- desc : desc. to_owned ( ) ,
494
+ short_name : short_name. to_string ( ) ,
495
+ long_name : long_name. to_string ( ) ,
496
+ hint : hint. to_string ( ) ,
497
+ desc : desc. to_string ( ) ,
498
498
hasarg : Maybe ,
499
499
occur : Optional
500
500
}
@@ -512,10 +512,10 @@ pub fn optmulti(short_name: &str, long_name: &str, desc: &str, hint: &str) -> Op
512
512
let len = short_name. len ( ) ;
513
513
assert ! ( len == 1 || len == 0 ) ;
514
514
OptGroup {
515
- short_name : short_name. to_owned ( ) ,
516
- long_name : long_name. to_owned ( ) ,
517
- hint : hint. to_owned ( ) ,
518
- desc : desc. to_owned ( ) ,
515
+ short_name : short_name. to_string ( ) ,
516
+ long_name : long_name. to_string ( ) ,
517
+ hint : hint. to_string ( ) ,
518
+ desc : desc. to_string ( ) ,
519
519
hasarg : Yes ,
520
520
occur : Multi
521
521
}
@@ -531,10 +531,10 @@ pub fn opt(short_name: &str,
531
531
let len = short_name. len ( ) ;
532
532
assert ! ( len == 1 || len == 0 ) ;
533
533
OptGroup {
534
- short_name : short_name. to_owned ( ) ,
535
- long_name : long_name. to_owned ( ) ,
536
- hint : hint. to_owned ( ) ,
537
- desc : desc. to_owned ( ) ,
534
+ short_name : short_name. to_string ( ) ,
535
+ long_name : long_name. to_string ( ) ,
536
+ hint : hint. to_string ( ) ,
537
+ desc : desc. to_string ( ) ,
538
538
hasarg : hasarg,
539
539
occur : occur
540
540
}
@@ -574,7 +574,7 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
574
574
let opts: Vec < Opt > = optgrps. iter ( ) . map ( |x| x. long_to_short ( ) ) . collect ( ) ;
575
575
let n_opts = opts. len ( ) ;
576
576
577
- fn f ( _x : usize ) -> Vec < Optval > { Vec :: new ( ) }
577
+ fn f ( _x : usize ) -> Vec < Optval > { return Vec :: new ( ) ; }
578
578
579
579
let mut vals: Vec < _ > = ( 0 ..n_opts) . map ( f) . collect ( ) ;
580
580
let mut free: Vec < String > = Vec :: new ( ) ;
@@ -596,11 +596,11 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
596
596
let tail = & cur[ 2 ..curlen] ;
597
597
let tail_eq: Vec < & str > = tail. split ( '=' ) . collect ( ) ;
598
598
if tail_eq. len ( ) <= 1 {
599
- names = vec ! ( Long ( tail. to_owned ( ) ) ) ;
599
+ names = vec ! ( Long ( tail. to_string ( ) ) ) ;
600
600
} else {
601
601
names =
602
- vec ! ( Long ( tail_eq[ 0 ] . to_owned ( ) ) ) ;
603
- i_arg = Some ( tail_eq[ 1 ] . to_owned ( ) ) ;
602
+ vec ! ( Long ( tail_eq[ 0 ] . to_string ( ) ) ) ;
603
+ i_arg = Some ( tail_eq[ 1 ] . to_string ( ) ) ;
604
604
}
605
605
} else {
606
606
let mut j = 1 ;
@@ -630,7 +630,7 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
630
630
631
631
let next = j + ch. len_utf8 ( ) ;
632
632
if arg_follows && next < curlen {
633
- i_arg = Some ( ( & cur[ next..curlen] ) . to_owned ( ) ) ;
633
+ i_arg = Some ( ( & cur[ next..curlen] ) . to_string ( ) ) ;
634
634
break ;
635
635
}
636
636
@@ -769,7 +769,7 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> String {
769
769
// FIXME: #5516 should be graphemes not codepoints
770
770
let mut desc_rows = Vec :: new ( ) ;
771
771
each_split_within ( & desc_normalized_whitespace[ ..] , 54 , |substr| {
772
- desc_rows. push ( substr. to_owned ( ) ) ;
772
+ desc_rows. push ( substr. to_string ( ) ) ;
773
773
true
774
774
} ) ;
775
775
@@ -936,7 +936,7 @@ fn each_split_within<F>(ss: &str, lim: usize, mut it: F) -> bool where
936
936
machine ( & mut cont, ( fake_i, ' ' ) ) ;
937
937
fake_i += 1 ;
938
938
}
939
- cont
939
+ return cont;
940
940
}
941
941
942
942
#[ test]
0 commit comments