Created
July 9, 2016 22:53
-
-
Save dumindu/674c1bd9e8676cac1109baded0b346ae to your computer and use it in GitHub Desktop.
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
// ------- code ---------- | |
use std::io; | |
fn main() { | |
println!("Type someting!"); | |
let mut input = String::new(); | |
match io::stdin().read_line(&mut input) { | |
Ok(n) => println!("You input {}({} bytes)", input, n), | |
Err(error) => println!("error: {}", error) | |
} | |
} | |
// ------- code ---------- | |
This is the output of terminal when I typed abc, up arrow key once and up arrow key twice | |
TempMac:Rust lazhcm10381$ ./test | |
Type someting! | |
abc | |
You input abc | |
(4 bytes) | |
TempMac:Rust lazhcm10381$ ./test | |
Type someting! | |
^[[A | |
(4 bytes) | |
TempMac:Rust lazhcm10381$ ./test | |
Type someting! | |
(7 bytes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment