Allow returning errors

This commit is contained in:
Manuel Thalmann 2025-03-19 08:20:48 +01:00
parent 009bb0cb96
commit 6a8a5c234e
Signed by: manuth
SSH key fingerprint: SHA256:HsMLC+7kJWALP6YCYCoopxNbUnghwSGLVcG76SECT5c

View file

@ -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 {