Add note about how to use tokio::main in examples (#745)
This commit is contained in:
@@ -4,6 +4,9 @@
|
|||||||
//! really care about the structure of the JSON and just need to display it or
|
//! really care about the structure of the JSON and just need to display it or
|
||||||
//! process it at runtime.
|
//! process it at runtime.
|
||||||
|
|
||||||
|
// This is using the `tokio` runtime. You'll need the following dependency:
|
||||||
|
//
|
||||||
|
// `tokio = { version = "0.2", features = ["macros"] }`
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), reqwest::Error> {
|
async fn main() -> Result<(), reqwest::Error> {
|
||||||
let echo_json: serde_json::Value = reqwest::Client::new()
|
let echo_json: serde_json::Value = reqwest::Client::new()
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ struct Post {
|
|||||||
user_id: i32,
|
user_id: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is using the `tokio` runtime. You'll need the following dependency:
|
||||||
|
//
|
||||||
|
// `tokio = { version = "0.2", features = ["macros"] }`
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), reqwest::Error> {
|
async fn main() -> Result<(), reqwest::Error> {
|
||||||
let new_post = Post {
|
let new_post = Post {
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
|
|
||||||
|
// This is using the `tokio` runtime. You'll need the following dependency:
|
||||||
|
//
|
||||||
|
// `tokio = { version = "0.2", features = ["macros"] }`
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), reqwest::Error> {
|
async fn main() -> Result<(), reqwest::Error> {
|
||||||
let res = reqwest::Client::new()
|
let res = reqwest::get("https://hyper.rs").await?;
|
||||||
.get("https://hyper.rs")
|
|
||||||
.send()
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
println!("Status: {}", res.status());
|
println!("Status: {}", res.status());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user