From 983269e71ac39cede5477f26fa1920819875e468 Mon Sep 17 00:00:00 2001 From: Ron Dahlgren Date: Sun, 9 Jun 2013 15:44:57 -0700 Subject: [PATCH 1/2] Updated documentation to refer to extra module The documentation was still refering to getopts as though it was in the std module - I've changed this to refer to extra instead. --- src/libextra/getopts.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libextra/getopts.rs b/src/libextra/getopts.rs index 2bc0a8ef6b0..c5c39381a24 100644 --- a/src/libextra/getopts.rs +++ b/src/libextra/getopts.rs @@ -31,8 +31,8 @@ * file name following -o, and accepts both -h and --help as optional flags. * * ``` - * extern mod std; - * use std::getopts::*; + * extern mod extra; + * use extra::getopts::*; * * fn do_work(in: &str, out: Option<~str>) { * io::println(in); @@ -42,7 +42,7 @@ * }); * } * - * fn print_usage(program: &str, _opts: &[std::getopts::Opt]) { + * fn print_usage(program: &str, _opts: &[extra::getopts::Opt]) { * io::println(fmt!("Usage: %s [options]", program)); * io::println("-o\t\tOutput"); * io::println("-h --help\tUsage"); From 9e4beaac9d6de2e867427f06e8420b8bac847181 Mon Sep 17 00:00:00 2001 From: Ron Dahlgren Date: Sun, 9 Jun 2013 16:13:52 -0700 Subject: [PATCH 2/2] Fix all issues with sample code The getopts sample program now compiles and runs. Additionally I made all of the indentation uniformly four spaces. --- src/libextra/getopts.rs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/libextra/getopts.rs b/src/libextra/getopts.rs index c5c39381a24..3460b65e876 100644 --- a/src/libextra/getopts.rs +++ b/src/libextra/getopts.rs @@ -33,19 +33,20 @@ * ``` * extern mod extra; * use extra::getopts::*; + * use std::os; * * fn do_work(in: &str, out: Option<~str>) { - * io::println(in); - * io::println(match out { - * Some(x) => x, - * None => ~"No Output" - * }); + * println(in); + * println(match out { + * Some(x) => x, + * None => ~"No Output" + * }); * } * - * fn print_usage(program: &str, _opts: &[extra::getopts::Opt]) { - * io::println(fmt!("Usage: %s [options]", program)); - * io::println("-o\t\tOutput"); - * io::println("-h --help\tUsage"); + * fn print_usage(program: &str, _opts: &[Opt]) { + * println(fmt!("Usage: %s [options]", program)); + * println("-o\t\tOutput"); + * println("-h --help\tUsage"); * } * * fn main() { @@ -58,9 +59,9 @@ * optflag("h"), * optflag("help") * ]; - * let matches = match getopts(vec::tail(args), opts) { - * result::Ok(m) => { m } - * result::Err(f) => { fail!(fail_str(f)) } + * let matches = match getopts(args.tail(), opts) { + * Ok(m) => { m } + * Err(f) => { fail!(fail_str(f)) } * }; * if opt_present(&matches, "h") || opt_present(&matches, "help") { * print_usage(program, opts);