以下代码为什么 panic ?应该怎么改?
use futures::executor::block_on;
async fn request() -> Result<(), reqwest::Error> {
let response = reqwest::get("https://rustcc.cn").await?; // Panic here according to backtrace
Ok(())
}
fn main() -> Result<(), reqwest::Error> {
block_on(request())
}
1
共 1 条评论, 1 页
评论区
写评论reqwest是tokio下的库,用futures的运行时运行会报错的,它注册异步事件时会发现没有找到运行时而panic,换成tokio runtime就好了