Created
January 21, 2017 21:13
-
-
Save matematikaadit/ce044ffc1e71f82a43bdaf2679c02ec4 to your computer and use it in GitHub Desktop.
using `Result<T, Box<Error>>` to allow `?` operator
This file contains hidden or 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
use std::error::Error; | |
fn run() -> Result<(), Box<Error>> { | |
let stdin = std::io::stdin(); | |
let mut buffer = String::new(); | |
stdin.read_line(&mut buffer)?; | |
let n: u32 = buffer.parse()?; | |
println!("{}", n); | |
Ok(()) | |
} | |
fn main() { | |
run().unwrap(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment