diff --git a/minigrep/src/main.rs b/minigrep/src/main.rs index 018a838..440c741 100644 --- a/minigrep/src/main.rs +++ b/minigrep/src/main.rs @@ -1,4 +1,5 @@ use std::env; +use std::error::Error; use std::fs; use std::process; @@ -16,11 +17,10 @@ fn main() { run(config); } -fn run(config: Config) { - let contents = fs::read_to_string(config.file_path) - .expect("Should have been able to read the file"); - +fn run(config: Config) -> Result<(), Box<dyn Error>> { + let contents = fs::read_to_string(config.file_path)?; println!("With text:\n{contents}"); + Ok(()) } struct Config {