Skip to content

Commit 0c20396

Browse files
committed
impl Generator for Pin<Box<Generator>>
1 parent 730b18b commit 0c20396

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/liballoc/boxed.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,16 @@ impl<G: ?Sized + Generator + Unpin> Generator for Box<G> {
882882
}
883883
}
884884

885+
#[unstable(feature = "generator_trait", issue = "43122")]
886+
impl<G: ?Sized + Generator> Generator for Pin<Box<G>> {
887+
type Yield = G::Yield;
888+
type Return = G::Return;
889+
890+
fn resume(mut self: Pin<&mut Self>) -> GeneratorState<Self::Yield, Self::Return> {
891+
G::resume((*self).as_mut())
892+
}
893+
}
894+
885895
#[unstable(feature = "futures_api", issue = "50547")]
886896
impl<F: ?Sized + Future + Unpin> Future for Box<F> {
887897
type Output = F::Output;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// run-pass
2+
3+
#![feature(generators, generator_trait)]
4+
5+
use std::ops::Generator;
6+
7+
fn assert_generator<G: Generator>(_: G) {
8+
}
9+
10+
fn main() {
11+
assert_generator(static || yield);
12+
assert_generator(Box::pin(static || yield));
13+
}

0 commit comments

Comments
 (0)