From 6a8541ad7f278148d7baa39ebfedad28d3b7acee Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Sun, 13 Jun 2021 14:25:03 -0700 Subject: [PATCH] grep: Update for Rust 2018. --- grep/Cargo.toml | 1 + grep/src/main.rs | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/grep/Cargo.toml b/grep/Cargo.toml index 14dc747..d228cc7 100644 --- a/grep/Cargo.toml +++ b/grep/Cargo.toml @@ -2,5 +2,6 @@ name = "grep" version = "0.1.0" authors = ["You "] +edition = "2018" [dependencies] diff --git a/grep/src/main.rs b/grep/src/main.rs index e6a128a..be67bc5 100644 --- a/grep/src/main.rs +++ b/grep/src/main.rs @@ -18,7 +18,7 @@ fn grep(target: &str, reader: R) -> io::Result<()> Ok(()) } -fn grep_main() -> Result<(), Box> { +fn grep_main() -> Result<(), Box> { // Get the command-line arguments. The first argument is the // string to search for; the rest are filenames. let mut args = std::env::args().skip(1); @@ -44,6 +44,7 @@ fn grep_main() -> Result<(), Box> { fn main() { let result = grep_main(); if let Err(err) = result { - let _ = writeln!(io::stderr(), "{}", err); + eprintln!("{}", err); + std::process::exit(1); } }