mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 23:34:48 +00:00
impl Generator for Pin<Box<Generator>>
This commit is contained in:
parent
730b18b6e5
commit
0c203965e2
@ -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;
|
||||
|
13
src/test/run-pass/generator/pin-box-generator.rs
Normal file
13
src/test/run-pass/generator/pin-box-generator.rs
Normal 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));
|
||||
}
|
Loading…
Reference in New Issue
Block a user