I'am trying to implement educational client-server application using Rust and Iron. I've encountered the behaviour that I can't understand. Here is the code:
fn main() {
Iron::new(hello_world).http("localhost:3000").unwrap();
let mut input = String::new();
io::stdin().read_line(&mut input)
.expect("Failed to read line");
println!("You entered: {}", &input)
}
fn hello_world(_: &mut Request) -> IronResult<Response> {
Ok(Response::with((status::Ok, "Hello World!")))
}
When I run it and try to enter something from the keyboard, the line You entered: Some text is not appearing.
But after I changed this line:
Iron::new(hello_world).http("localhost:3000").unwrap();
With this:
let listener = Iron::new(hello_world).http("localhost:3000").unwrap();
I got string You entered: Some text on my console. So it seems to work. But now I have warning about unused variable. This behaviour is confusing.
Can anyone explain why this actually happens?