input loop
This commit is contained in:
20
src/main.rs
20
src/main.rs
@@ -1,3 +1,23 @@
|
||||
use std::io;
|
||||
use std::io::Write;
|
||||
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
|
||||
loop {
|
||||
let mut input = String::new();
|
||||
print!("> ");
|
||||
|
||||
io::stdout()
|
||||
.flush()
|
||||
.expect("flush to stdout should not fail");
|
||||
|
||||
io::stdin()
|
||||
.read_line(&mut input)
|
||||
.expect("failed to read line");
|
||||
|
||||
let output = input.trim();
|
||||
|
||||
println!("input received: '{output}'");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user