Is it possible to read and write to an active input stream in Rust?
assuming this code:
print!("[{}]>> ", line);
io::stdout().flush();
line += 1;
let mut input = String::new();
io::stdin().read_line(&mut input)?;
I would like to read individual characters as they are being inputted. My use-case would be for a REPL application where the user is asked for an input:
[0]>>
and in the case (
is inputted:
[0]>> (
I would like to auto-match the closing parenthesis and place the cursor in between the parentheses:
[0]>> ( )
For this functionality, I would need to be able to both read the individual characters and be able to mutate the stream structure while receiving input, and I am currently unaware of how to do so.
Any help appreciated