问题描述
我在 rust 中使用 tokio
进行异步处理,在 rust 中我正在调用使用 async
和 .await
进行异步处理的函数,但是我可以包装这些函数吗以某种方式并在没有 async
的函数中调用它们?下面是我想要做的伪代码。
async fn asynchronous_func() -> Vec<u32> {
let vec = Arc::new(Mutex::new(vec![]));
// do something await
let vec = Arc::try_unwrap(vec).unwrap();
let vec = vec.try_inner().unwrap();
vec
}
// without async
fn wrapper_func() -> Vec<u32> {
let res = asynchronous_func().await;
// do something
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)