3 ms·
expression.await
by thsowers 7y ago
expression.await
- nailer 7y agoCan you show us an example of, eg, an HTTP request?
- steveklabnik 7y agoHere is a small TCP client example: https://github.com/rustasync/runtime/blob/master/examples/tcp-client.rs https://github.com/rustasync/runtime/blob/master/examples/tc... Note "async fn main" on line 15, and the ".await"s on 21 and 24. Now, if you read my other comment about executors, this is using a crate called "runtime", which handles submitting it for you, see the `#[]` bit on line 14. Regardless, the syntax would look like this even without this crate; it just removes some boilerplate around the executor and submitting your future to it.
- mrkurt 7y agoIt's basically just like a method call on a future: use hyper::Client; let client = Client::new(); let resp = client.get(url).await;