Rust and Cargo 1 · Code patterns
Propagate errors with ?
Return early with the error when a call fails.
fn read_config(path: &str) -> Result<String, std::io::Error> {
let text = std::fs::read_to_string(path)?;
Ok(text)
}
Official Rust and Cargo 1 documentation