Skip to content

Commit 9e4beaa

Browse files
author
Ron Dahlgren
committed
Fix all issues with sample code
The getopts sample program now compiles and runs. Additionally I made all of the indentation uniformly four spaces.
1 parent 983269e commit 9e4beaa

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/libextra/getopts.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,20 @@
3333
* ```
3434
* extern mod extra;
3535
* use extra::getopts::*;
36+
* use std::os;
3637
*
3738
* fn do_work(in: &str, out: Option<~str>) {
38-
* io::println(in);
39-
* io::println(match out {
40-
* Some(x) => x,
41-
* None => ~"No Output"
42-
* });
39+
* println(in);
40+
* println(match out {
41+
* Some(x) => x,
42+
* None => ~"No Output"
43+
* });
4344
* }
4445
*
45-
* fn print_usage(program: &str, _opts: &[extra::getopts::Opt]) {
46-
* io::println(fmt!("Usage: %s [options]", program));
47-
* io::println("-o\t\tOutput");
48-
* io::println("-h --help\tUsage");
46+
* fn print_usage(program: &str, _opts: &[Opt]) {
47+
* println(fmt!("Usage: %s [options]", program));
48+
* println("-o\t\tOutput");
49+
* println("-h --help\tUsage");
4950
* }
5051
*
5152
* fn main() {
@@ -58,9 +59,9 @@
5859
* optflag("h"),
5960
* optflag("help")
6061
* ];
61-
* let matches = match getopts(vec::tail(args), opts) {
62-
* result::Ok(m) => { m }
63-
* result::Err(f) => { fail!(fail_str(f)) }
62+
* let matches = match getopts(args.tail(), opts) {
63+
* Ok(m) => { m }
64+
* Err(f) => { fail!(fail_str(f)) }
6465
* };
6566
* if opt_present(&matches, "h") || opt_present(&matches, "help") {
6667
* print_usage(program, opts);

0 commit comments

Comments
 (0)