Skip to content

Instantly share code, notes, and snippets.

@dumindu
Created July 9, 2016 22:53
Show Gist options
  • Save dumindu/674c1bd9e8676cac1109baded0b346ae to your computer and use it in GitHub Desktop.
Save dumindu/674c1bd9e8676cac1109baded0b346ae to your computer and use it in GitHub Desktop.
// ------- 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