Skip to content

Instantly share code, notes, and snippets.

@matematikaadit
Created January 21, 2017 21:13
Show Gist options
  • Save matematikaadit/ce044ffc1e71f82a43bdaf2679c02ec4 to your computer and use it in GitHub Desktop.
Save matematikaadit/ce044ffc1e71f82a43bdaf2679c02ec4 to your computer and use it in GitHub Desktop.
using `Result<T, Box<Error>>` to allow `?` operator
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