Add Error to Result added note for tokio

Added error to Result for main, otherwise it won't compile.
If tokio isn't added with features = ["full"] main won't work, so I thought it would be a good idea to remind them.
This commit is contained in:
sain-VO 2022-10-05 13:19:07 +01:00 committed by GitHub
parent 752b035c1a
commit 2917aa9e17
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -37,6 +37,8 @@ fn main() -> Result<()> {
A similar approach can be used by including the [`tokio`] executor
to make the main function asynchronous, retrieving the same information.
Make sure to add tokio = {version = "1.21.2", features = ["full"]} to
your cargo.toml file.
In this example, [`tokio::main`] handles all the heavy executor setup
and allows sequential code implemented without blocking until `.await`.
@ -55,7 +57,7 @@ error_chain! {
}
#[tokio::main]
async fn main() -> Result<()> {
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let res = reqwest::get("http://httpbin.org/get").await?;
println!("Status: {}", res.status());
println!("Headers:\n{:#?}", res.headers());