Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Code shared from the Rust Playground
fn main() -> Result<(), Box<dyn std::fmt::Debug>> {
let contents =
std::fs::read_to_string("my.txt").map_err(|e| Box::new(e) as Box<dyn std::fmt::Debug>)?;
let number = contents
.parse::<i32>()
.map_err(|e| Box::new(e) as Box<dyn std::fmt::Debug>)?;
println!("Number is {}!", number);
return Ok(());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.