Allow returning errors
This commit is contained in:
parent
009bb0cb96
commit
6a8a5c234e
1 changed files with 4 additions and 4 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue