- 
                Notifications
    You must be signed in to change notification settings 
- Fork 10
Open
Description
The example on the front page never prints "On 3000" because the lifetime of the Listening returned from http().unwrap() expires within its own statement and then blocks the program.  The solution to this is to store this value in an unused variable so that its lifetime is extended until the end of the block.
For example:
let _listener = Iron::new(hello_world).http("localhost:3000").unwrap();The leading _ suppresses unused variable warnings (but note that it cannot just be called _ since that has no lifetime).
It would also be good to add a note to the Iron.http and Iron.https methods where they discuss the guard to explain how to prevent it blocking.
Metadata
Metadata
Assignees
Labels
No labels