如何在新的未来 API 中删除未来的类型?

How do I erase the type of future in the new future API?

The following does not compile

#![feature(await_macro, async_await, futures_api)]
use core::future::Future;

async fn foo() {}

trait Bar {
    type Output: Future<Output = ()>;
    fn bar(&self) -> Self::Output;
}

impl Bar for () {
    type Output = Box<dyn Future<Output = ()>>;
    fn bar(&self) -> Self::Output {
        Box::new(foo())
    }
}

async fn buz() {
    await!(().bar())
}
error[E0277]: the trait bound `(dyn std::future::Future<Output=()> + 'static): std::marker::Unpin` is not satisfied
  --> src/lib.rs:19:15
   |
19 |     await!(().bar())
   |               ^^^ the trait `std::marker::Unpin` is not implemented for `(dyn std::future::Future<Output=()> + 'static)`
   |
   = note: required because of the requirements on the impl of `std::future::Future` for `std::boxed::Box<(dyn std::future::Future<Output=()> + 'static)>`

error[E0277]: the trait bound `dyn std::future::Future<Output=()>: std::marker::Unpin` is not satisfied
  --> src/lib.rs:19:5
   |
19 |     await!(().bar())
   |     ^^^^^^^^^^^^^^^^ the trait `std::marker::Unpin` is not implemented for `dyn std::future::Future<Output=()>`
   |
   = note: required because of the requirements on the impl of `std::future::Future` for `std::boxed::Box<dyn std::future::Future<Output=()>>`
   = note: required by `std::future::poll_with_tls_waker`
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

如何设置类型Output?我希望通过调用 foo bar 到 return 一些 Future 这样我就可以 await! in buz.

在过去使用 Future<Item = (), Error = ()> 的时候,上面的编译没有任何问题,因为我们没有 Unpin 约束,但我们也没有 await

Box 包裹在 Pin 中:

impl Bar for () {
    type Output = Pin<Box<dyn Future<Output = ()>>>;
    fn bar(&self) -> Self::Output {
        Box::pin(foo())
    }
}