impl Generator for Pin<Box<Generator>>

This commit is contained in:
Wim Looman 2018-11-06 19:47:18 +01:00
parent 730b18b6e5
commit 0c203965e2
2 changed files with 23 additions and 0 deletions

View File

@ -882,6 +882,16 @@ impl<G: ?Sized + Generator + Unpin> Generator for Box<G> {
}
}
#[unstable(feature = "generator_trait", issue = "43122")]
impl<G: ?Sized + Generator> Generator for Pin<Box<G>> {
type Yield = G::Yield;
type Return = G::Return;
fn resume(mut self: Pin<&mut Self>) -> GeneratorState<Self::Yield, Self::Return> {
G::resume((*self).as_mut())
}
}
#[unstable(feature = "futures_api", issue = "50547")]
impl<F: ?Sized + Future + Unpin> Future for Box<F> {
type Output = F::Output;

View File

@ -0,0 +1,13 @@
// run-pass
#![feature(generators, generator_trait)]
use std::ops::Generator;
fn assert_generator<G: Generator>(_: G) {
}
fn main() {
assert_generator(static || yield);
assert_generator(Box::pin(static || yield));
}