input loop

This commit is contained in:
2023-09-07 13:07:55 -04:00
parent dfd813600d
commit a0d3ad8f01

View File

@@ -1,3 +1,23 @@
use std::io;
use std::io::Write;
fn main() { fn main() {
println!("Hello, world!"); 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}'");
}
} }