I'm running this hello world example code from the http://ironframework.io homepage:
extern crate iron;
use iron::prelude::*;
use iron::status;
fn main() {
fn hello_world(_: &mut Request) -> IronResult<Response> {
Ok(Response::with((status::Ok, "Hello World!")))
}
Iron::new(hello_world).http("localhost:3000").unwrap();
println!("On 3000");
}
I expected to see "On 3000" appear on standard out, but it never appears. My guess is that the main thread is being blocked before it executes the println. Why is that happening?
If I use a temporary and call unwrap afterwards, I get the expected output:
fn main() {
fn hello_world(_: &mut Request) -> IronResult<Response> {
Ok(Response::with((status::Ok, "Hello World!")))
}
let result = Iron::new(hello_world).http("localhost:3000");
println!("On 3000");
result.unwrap();
}
Why is it that the behavior changes when unwrap is called on the return value?
I'm running rust 1.1.0 and iron 0.1.20.