Result and the question mark operator in Rust
Rust? propagates the error to the caller, which is why Rust functions rarely need explicit error branches.
use std::fs;
fn read_config(path: &str) -> Result<Config, Box<dyn std::error::Error>> {
let text = fs::read_to_string(path)?;
let config: Config = toml::from_str(&text)?;
Ok(config)
}