grep: Update for Rust 2018.

pull/13/head
Jim Blandy 3 years ago
parent 807b796c3b
commit 6a8541ad7f

@ -2,5 +2,6 @@
name = "grep" name = "grep"
version = "0.1.0" version = "0.1.0"
authors = ["You <you@example.com>"] authors = ["You <you@example.com>"]
edition = "2018"
[dependencies] [dependencies]

@ -18,7 +18,7 @@ fn grep<R>(target: &str, reader: R) -> io::Result<()>
Ok(()) Ok(())
} }
fn grep_main() -> Result<(), Box<Error>> { fn grep_main() -> Result<(), Box<dyn Error>> {
// Get the command-line arguments. The first argument is the // Get the command-line arguments. The first argument is the
// string to search for; the rest are filenames. // string to search for; the rest are filenames.
let mut args = std::env::args().skip(1); let mut args = std::env::args().skip(1);
@ -44,6 +44,7 @@ fn grep_main() -> Result<(), Box<Error>> {
fn main() { fn main() {
let result = grep_main(); let result = grep_main();
if let Err(err) = result { if let Err(err) = result {
let _ = writeln!(io::stderr(), "{}", err); eprintln!("{}", err);
std::process::exit(1);
} }
} }

Loading…
Cancel
Save