8585 html_root_url = "http://static.rust-lang.org/doc/master" ) ] ;
8686#[ feature( globs, phase) ] ;
8787#[ deny( missing_doc) ] ;
88- #[ allow ( deprecated_owned_vector) ] ; // NOTE: remove after stage0
88+ #[ deny ( deprecated_owned_vector) ] ;
8989
9090#[ cfg( test) ] #[ phase( syntax, link) ] extern crate log;
9191
@@ -516,7 +516,7 @@ impl Fail_ {
516516/// `opt_str`, etc. to interrogate results. Returns `Err(Fail_)` on failure.
517517/// Use `to_err_msg` to get an error message.
518518pub 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 ( ) ;
520520 let n_opts = opts. len ( ) ;
521521
522522 fn f ( _x : uint ) -> Vec < Optval > { return Vec :: new ( ) ; }
@@ -562,12 +562,12 @@ pub fn getopts(args: &[~str], optgrps: &[OptGroup]) -> Result {
562562 interpreted correctly
563563 */
564564
565- match find_opt(opts, opt.clone()) {
565+ match find_opt(opts.as_slice() , opt.clone()) {
566566 Some(id) => last_valid_opt_id = Some(id),
567567 None => {
568568 let arg_follows =
569569 last_valid_opt_id.is_some() &&
570- match opts[ last_valid_opt_id.unwrap()]
570+ match opts.get( last_valid_opt_id.unwrap())
571571 .hasarg {
572572
573573 Yes | Maybe => true,
@@ -588,11 +588,11 @@ pub fn getopts(args: &[~str], optgrps: &[OptGroup]) -> Result {
588588 let mut name_pos = 0;
589589 for nm in names.iter() {
590590 name_pos += 1;
591- let optid = match find_opt(opts, (*nm).clone()) {
591+ let optid = match find_opt(opts.as_slice() , (*nm).clone()) {
592592 Some(id) => id,
593593 None => return Err(UnrecognizedOption(nm.to_str()))
594594 };
595- match opts[ optid] .hasarg {
595+ match opts.get( optid) .hasarg {
596596 No => {
597597 if !i_arg.is_none() {
598598 return Err(UnexpectedArgument(nm.to_str()));
@@ -630,21 +630,21 @@ pub fn getopts(args: &[~str], optgrps: &[OptGroup]) -> Result {
630630 i = 0u;
631631 while i < n_opts {
632632 let n = vals.get(i).len();
633- let occ = opts[i] .occur;
633+ let occ = opts.get(i) .occur;
634634 if occ == Req {
635635 if n == 0 {
636- return Err(OptionMissing(opts[i] .name.to_str()));
636+ return Err(OptionMissing(opts.get(i) .name.to_str()));
637637 }
638638 }
639639 if occ != Multi {
640640 if n > 1 {
641- return Err(OptionDuplicated(opts[i] .name.to_str()));
641+ return Err(OptionDuplicated(opts.get(i) .name.to_str()));
642642 }
643643 }
644644 i += 1;
645645 }
646646 Ok(Matches {
647- opts: Vec::from_slice( opts) ,
647+ opts: opts,
648648 vals: vals,
649649 free: free
650650 })
@@ -772,7 +772,7 @@ fn format_option(opt: &OptGroup) -> ~str {
772772/// Derive a short one-line usage summary from a set of long options.
773773pub fn short_usage ( program_name : & str , opts : & [ OptGroup ] ) -> ~str {
774774 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(" "));
776776
777777 line
778778}
0 commit comments