diff --git a/README.md b/README.md index b80b71e..7d1e984 100644 --- a/README.md +++ b/README.md @@ -61,13 +61,21 @@ Whether it's a quick script, or a cross-platform SDK, Surf will make it work. ## Examples ```rust -let mut res = surf::get("https://httpbin.org/get").await?; -dbg!(res.body_string().await?); +#[async_std::main] +async fn main() -> Result<(), surf::Error> { + let mut res = surf::get("https://httpbin.org/get").await?; + dbg!(res.body_string().await?); + Ok(()) +} ``` It's also possible to skip the intermediate `Response`, and access the response type directly. ```rust -dbg!(surf::get("https://httpbin.org/get").recv_string().await?); +#[async_std::main] +async fn main() -> Result<(), surf::Error> { + dbg!(surf::get("https://httpbin.org/get").recv_string().await?); + Ok(()) +} ``` Both sending and receiving JSON is real easy too.