From f78846b6f15e82e60c8a83e7b3a7137e19f94884 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Tue, 17 Dec 2019 12:56:36 -0800 Subject: [PATCH] Add note about how to use tokio::main in examples (#745) --- examples/json_dynamic.rs | 3 +++ examples/json_typed.rs | 3 +++ examples/simple.rs | 8 ++++---- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/examples/json_dynamic.rs b/examples/json_dynamic.rs index 5673420..0ec47d6 100644 --- a/examples/json_dynamic.rs +++ b/examples/json_dynamic.rs @@ -4,6 +4,9 @@ //! really care about the structure of the JSON and just need to display it or //! process it at runtime. +// This is using the `tokio` runtime. You'll need the following dependency: +// +// `tokio = { version = "0.2", features = ["macros"] }` #[tokio::main] async fn main() -> Result<(), reqwest::Error> { let echo_json: serde_json::Value = reqwest::Client::new() diff --git a/examples/json_typed.rs b/examples/json_typed.rs index 16a329f..44bc608 100644 --- a/examples/json_typed.rs +++ b/examples/json_typed.rs @@ -15,6 +15,9 @@ struct Post { user_id: i32, } +// This is using the `tokio` runtime. You'll need the following dependency: +// +// `tokio = { version = "0.2", features = ["macros"] }` #[tokio::main] async fn main() -> Result<(), reqwest::Error> { let new_post = Post { diff --git a/examples/simple.rs b/examples/simple.rs index 0652cbf..b5a9adc 100644 --- a/examples/simple.rs +++ b/examples/simple.rs @@ -1,11 +1,11 @@ #![deny(warnings)] +// This is using the `tokio` runtime. You'll need the following dependency: +// +// `tokio = { version = "0.2", features = ["macros"] }` #[tokio::main] async fn main() -> Result<(), reqwest::Error> { - let res = reqwest::Client::new() - .get("https://hyper.rs") - .send() - .await?; + let res = reqwest::get("https://hyper.rs").await?; println!("Status: {}", res.status());