Skip to content

Instantly share code, notes, and snippets.

@philopon
Created March 12, 2020 17:52
Show Gist options
  • Save philopon/c9a0c56684472b31966e1053d98b7131 to your computer and use it in GitHub Desktop.
Save philopon/c9a0c56684472b31966e1053d98b7131 to your computer and use it in GitHub Desktop.
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(())
}
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