From a36386210293cf12f771adb6bc775a45cab6b4da Mon Sep 17 00:00:00 2001 From: Ben Kelly Date: Sun, 10 Mar 2013 13:27:11 -0400 Subject: [PATCH 1/2] Fix formatting and errors in std::getopts example. There were three issues effecting the example in the getopts rustdoc: 1. The blockquote was incorrectly formatted. Fixed by switching to using an explicit markdown code section with ```. 2. The `fail fail_str(f)` would not compile. Fixed by using `fail!()` instead of `fail`. 3. The line `matches.free[0]` produced a compile error about moving from an immutable vector. Fix by using `copy`. --- src/libstd/getopts.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs index 2090a3728db52..d3f1ed72edceb 100644 --- a/src/libstd/getopts.rs +++ b/src/libstd/getopts.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2011-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -29,8 +29,10 @@ * The following example shows simple command line parsing for an application * that requires an input file to be specified, accepts an optional output * file name following -o, and accepts both -h and --help as optional flags. - * extern mod std; - * use std::getopts::*; + * + * ``` + * extern mod std; + * use std::getopts::*; * * fn do_work(in: &str, out: Option<~str>) { * io::println(in); @@ -58,7 +60,7 @@ * ]; * let matches = match getopts(vec::tail(args), opts) { * result::Ok(m) => { m } - * result::Err(f) => { fail fail_str(f) } + * result::Err(f) => { fail!(fail_str(f)) } * }; * if opt_present(&matches, "h") || opt_present(&matches, "help") { * print_usage(program, opts); @@ -66,13 +68,14 @@ * } * let output = opt_maybe_str(&matches, "o"); * let input: &str = if !matches.free.is_empty() { - * matches.free[0] + * copy matches.free[0] * } else { * print_usage(program, opts); * return; * }; * do_work(input, output); * } + * ``` */ use core::cmp::Eq; From 13e58597a18d3d4a696bdd84750839655580ea55 Mon Sep 17 00:00:00 2001 From: Ben Kelly Date: Sun, 10 Mar 2013 20:47:28 -0400 Subject: [PATCH 2/2] Correct copyright year to be 2012-2013. Previous year range of 2011-2013 was based on file creation date. The check_license python script, however, only accepts copyrights starting in 2012 or later. --- src/libstd/getopts.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs index d3f1ed72edceb..eed00ccacffcc 100644 --- a/src/libstd/getopts.rs +++ b/src/libstd/getopts.rs @@ -1,4 +1,4 @@ -// Copyright 2011-2013 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. //