Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Can you show us an example of, eg, an HTTP request?


Here is a small TCP client example: 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.


It's basically just like a method call on a future:

    use hyper::Client;
    let client = Client::new();

    let resp = client.get(url).await;




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: