Created
March 12, 2020 17:52
-
-
Save philopon/c9a0c56684472b31966e1053d98b7131 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use anyhow::Result; | |
use futures::{executor::ThreadPool, task::SpawnExt}; | |
#[async_std::main] | |
async fn main() -> Result<()> { | |
let pool = ThreadPool::new()?; | |
let fut = async { | |
let resp = surf::get("https://google.com").await; | |
println!("{:?}", resp); | |
}; | |
let v = pool.spawn_with_handle(fut)?.await; | |
println!("{:?}", v); | |
Ok(()) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use anyhow::Result; | |
use futures::{executor::ThreadPool, task::SpawnExt}; | |
#[tokio::main] | |
async fn main() -> Result<()> { | |
let pool = ThreadPool::new()?; | |
let fut = async { | |
let resp = reqwest::get("https://google.com").await; | |
println!("{:?}", resp); | |
}; | |
let v = pool.spawn_with_handle(fut)?.await; | |
println!("{:?}", v); | |
Ok(()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment