Created
July 22, 2019 06:09
-
-
Save rust-play/26cce491505376bf8c6e0bf95f4c24a6 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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