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::env;
|
||||||
|
use std::error::Error;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::process;
|
use std::process;
|
||||||
|
|
||||||
|
@ -16,11 +17,10 @@ fn main() {
|
||||||
run(config);
|
run(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run(config: Config) {
|
fn run(config: Config) -> Result<(), Box<dyn Error>> {
|
||||||
let contents = fs::read_to_string(config.file_path)
|
let contents = fs::read_to_string(config.file_path)?;
|
||||||
.expect("Should have been able to read the file");
|
|
||||||
|
|
||||||
println!("With text:\n{contents}");
|
println!("With text:\n{contents}");
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Config {
|
struct Config {
|
||||||
|
|
Loading…
Reference in a new issue