You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
The example on the front page never prints "On 3000" because the lifetime of the
Listening
returned fromhttp().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:
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
andIron.https
methods where they discuss the guard to explain how to prevent it blocking.The text was updated successfully, but these errors were encountered: