Skip to content

Instantly share code, notes, and snippets.

@PerArneng
Created January 27, 2016 21:19
Show Gist options
  • Save PerArneng/dd83ca578963887d7ec0 to your computer and use it in GitHub Desktop.
Save PerArneng/dd83ca578963887d7ec0 to your computer and use it in GitHub Desktop.
use std::io;
use std::io::Write;
fn main() {
let mut input = String::new();
let result = io::stdin().read_line(&mut input)
.map(|s:usize| input)
.and_then(|s:String| s.parse::<u32>());
println!("{}", result.unwrap());
}
@PerArneng
Copy link
Author

$ rustc test.rs 
test.rs:10:28: 10:44 error: mismatched types:
 expected `core::result::Result<_, std::io::error::Error>`,
    found `core::result::Result<u32, core::num::ParseIntError>`
(expected struct `std::io::error::Error`,
    found struct `core::num::ParseIntError`) [E0308]
test.rs:10                                              .and_then(|s:String| s.parse::<u32>());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment