Hi there,
I'm trying to implement some port from Erlang to Rust.
Here's my Rust code:
use std::io;
fn main() {
println!("{}", "test0");
loop {
let mut guess = String::new();
println!("test1");
io::stdin()
.read_line(&mut guess)
.expect("failed");
println!("test2");
println!("You guess {}", guess);
}
}
Erlang code:
P = open_port({spawn, main}, []).
P ! {self(), {command, "aaa"}}.
flush().
This flush() shows me
Shell got {#Port<0.6>,{data,"test0\ntest1\n"}}
which means nothing comes into my io::stdin()...
That's probably a really dumb question, but I could not get how to read data from stdin (file descriptor 0) in Rust in this case (meaning that data is not a user's input).