pub async fn run_dyn_test<T>(f: Box<dyn Future<Output = T>>) -> T {
*f.await
}
error[E0277]: `dyn std::future::Future<Output = T>` cannot be unpinned
--> src\util\common_util.rs:15:7
|
15 | *f.await
| ^^^^^^ the trait `Unpin` is not implemented for `dyn std::future::Future<Output = T>`
|
= note: consider using `Box::pin`
= note: required because of the requirements on the impl of `std::future::Future` for `Box<dyn std::future::Future<Output = T>>`
= note: required because of the requirements on the impl of `IntoFuture` for `Box<dyn std::future::Future<Output = T>>`
help: remove the `.await`
|
15 - *f.await
15 + *f
|
error[E0614]: type `T` cannot be dereferenced
--> src\util\common_util.rs:15:5
|
15 | *f.await
|
大佬们, 有没有办法解决
1
共 3 条评论, 1 页
评论区
写评论Box是有所有权的,只要不解引用就啥事没有
感谢
--
👇
Easonzero: ```rust pub async fn run_dyn_test(f: Pin<Box<dyn Future<Output = T>>>) -> T { f.await }