Logo

Programming-Idioms

History of Idiom 120 > diff from v32 to v33

Edit summary for version 33 by freecoder:
New Rust implementation by user [freecoder]

Version 32

2018-11-23, 05:41:45

Version 33

2018-12-17, 18:56:59

Idiom #120 Read integer from stdin

Read an integer value from the standard input into variable n.

Idiom #120 Read integer from stdin

Read an integer value from the standard input into variable n.

Imports
use std::io::{self, Read};
Code
let mut buffer = String::new();
io::stdin().read_to_string(&mut buffer).unwrap();
let n: i32 = buffer.trim().parse().unwrap();