Repository: seanmonstar/reqwest (language: rust)

Issue:
Clarify use of `#[tokio::main]`
This is also an issue in hyperium/hyper#2028.

Basically, the #[tokio::main] macro is used for examples but the dependency is not explicitly mentioned in readme or docs. Could be pretty confusing. I haven't seen an issue with reqwest yet, so this is preemptive, but I've seen people have issues with hyper and warp.

Also, the dep should look something like:

tokio = { version = "0.2.3", features = ["macros"] }



Discussion / hints:
Yes, I'm running into a similar issue trying to follow the github examples. Essentially I'm getting 

` --> src/main.rs:4:3
  |
4 | #[tokio::main]
  |   ^^^^^ use of undeclared type or module `tokio`
`

But I can't find any documentation about how to properly use this anywhere.

I was able to eventually get it to work by adding `tokio = "0.2.0-alpha.6"` to my Cargo.toml, but I had to try a bunch of different versions until I could find one that worked. 

I feel that this should be listed in the Requirements section on the README.md file if it's going to be included in all the examples. 
@anthonyjchriste note that when using the non-alpha version of tokio, you'll have to use the feature "macros", see original comment.

The need to specify features is because of an architectural change to the whole tokio crate, I can explain more or provide a look if needed, but I'm on phone at the moment.

Fix patch:
diff --git a/examples/json_dynamic.rs b/examples/json_dynamic.rs
index 5673420fe..0ec47d680 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 16a329fbe..44bc608d9 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 0652cbf50..b5a9adcd4 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());
 


Test patch: