85
85
html_root_url = "http://static.rust-lang.org/doc/master" ) ] ;
86
86
#[ feature( globs, phase) ] ;
87
87
#[ deny( missing_doc) ] ;
88
- #[ allow ( deprecated_owned_vector) ] ; // NOTE: remove after stage0
88
+ #[ deny ( deprecated_owned_vector) ] ;
89
89
90
90
#[ cfg( test) ] #[ phase( syntax, link) ] extern crate log;
91
91
@@ -516,7 +516,7 @@ impl Fail_ {
516
516
/// `opt_str`, etc. to interrogate results. Returns `Err(Fail_)` on failure.
517
517
/// Use `to_err_msg` to get an error message.
518
518
pub fn getopts ( args : & [ ~str ] , optgrps : & [ OptGroup ] ) -> Result {
519
- let opts = optgrps. map ( |x| x. long_to_short ( ) ) ;
519
+ let opts: Vec < Opt > = optgrps. iter ( ) . map ( |x| x. long_to_short ( ) ) . collect ( ) ;
520
520
let n_opts = opts. len ( ) ;
521
521
522
522
fn f ( _x : uint ) -> Vec < Optval > { return Vec :: new ( ) ; }
@@ -562,12 +562,12 @@ pub fn getopts(args: &[~str], optgrps: &[OptGroup]) -> Result {
562
562
interpreted correctly
563
563
*/
564
564
565
- match find_opt(opts, opt.clone()) {
565
+ match find_opt(opts.as_slice() , opt.clone()) {
566
566
Some(id) => last_valid_opt_id = Some(id),
567
567
None => {
568
568
let arg_follows =
569
569
last_valid_opt_id.is_some() &&
570
- match opts[ last_valid_opt_id.unwrap()]
570
+ match opts.get( last_valid_opt_id.unwrap())
571
571
.hasarg {
572
572
573
573
Yes | Maybe => true,
@@ -588,11 +588,11 @@ pub fn getopts(args: &[~str], optgrps: &[OptGroup]) -> Result {
588
588
let mut name_pos = 0;
589
589
for nm in names.iter() {
590
590
name_pos += 1;
591
- let optid = match find_opt(opts, (*nm).clone()) {
591
+ let optid = match find_opt(opts.as_slice() , (*nm).clone()) {
592
592
Some(id) => id,
593
593
None => return Err(UnrecognizedOption(nm.to_str()))
594
594
};
595
- match opts[ optid] .hasarg {
595
+ match opts.get( optid) .hasarg {
596
596
No => {
597
597
if !i_arg.is_none() {
598
598
return Err(UnexpectedArgument(nm.to_str()));
@@ -630,21 +630,21 @@ pub fn getopts(args: &[~str], optgrps: &[OptGroup]) -> Result {
630
630
i = 0u;
631
631
while i < n_opts {
632
632
let n = vals.get(i).len();
633
- let occ = opts[i] .occur;
633
+ let occ = opts.get(i) .occur;
634
634
if occ == Req {
635
635
if n == 0 {
636
- return Err(OptionMissing(opts[i] .name.to_str()));
636
+ return Err(OptionMissing(opts.get(i) .name.to_str()));
637
637
}
638
638
}
639
639
if occ != Multi {
640
640
if n > 1 {
641
- return Err(OptionDuplicated(opts[i] .name.to_str()));
641
+ return Err(OptionDuplicated(opts.get(i) .name.to_str()));
642
642
}
643
643
}
644
644
i += 1;
645
645
}
646
646
Ok(Matches {
647
- opts: Vec::from_slice( opts) ,
647
+ opts: opts,
648
648
vals: vals,
649
649
free: free
650
650
})
@@ -772,7 +772,7 @@ fn format_option(opt: &OptGroup) -> ~str {
772
772
/// Derive a short one-line usage summary from a set of long options.
773
773
pub fn short_usage ( program_name : & str , opts : & [ OptGroup ] ) -> ~str {
774
774
let mut line = ~"Usage : " + program_name + " ";
775
- line.push_str(opts.iter().map(format_option).to_owned_vec ().connect(" "));
775
+ line.push_str(opts.iter().map(format_option).collect::<Vec<~str>> ().connect(" "));
776
776
777
777
line
778
778
}
0 commit comments