Skip to content

Commit 6a8541a

Browse files
committed
grep: Update for Rust 2018.
1 parent 807b796 commit 6a8541a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

grep/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
name = "grep"
33
version = "0.1.0"
44
authors = ["You <[email protected]>"]
5+
edition = "2018"
56

67
[dependencies]

grep/src/main.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fn grep<R>(target: &str, reader: R) -> io::Result<()>
1818
Ok(())
1919
}
2020

21-
fn grep_main() -> Result<(), Box<Error>> {
21+
fn grep_main() -> Result<(), Box<dyn Error>> {
2222
// Get the command-line arguments. The first argument is the
2323
// string to search for; the rest are filenames.
2424
let mut args = std::env::args().skip(1);
@@ -44,6 +44,7 @@ fn grep_main() -> Result<(), Box<Error>> {
4444
fn main() {
4545
let result = grep_main();
4646
if let Err(err) = result {
47-
let _ = writeln!(io::stderr(), "{}", err);
47+
eprintln!("{}", err);
48+
std::process::exit(1);
4849
}
4950
}

0 commit comments

Comments
 (0)