I'm trying to get user input from the command line in a more visually pleasing way by printing ">> " before reading what the user types in. Then I simply print what was typed in.
use std::io;
fn get_input() -> Result<String, io::Error> {
print!(">> ");
let mut result = String::new();
io::stdin().read_line(&mut result)?;
Ok(result)
}
fn main() {
let string = get_input().expect("couldn't read input");
let string = string.trim();
println!("== {}", string);
}
When running the above program and typing "test" into the terminal, why is the output of the code snippet this:
test
>> == test
and not this?
>> test
== test