We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c0dfeda commit 1546558Copy full SHA for 1546558
core/src/lib.rs
@@ -37,11 +37,11 @@ pub mod future {
37
impl<T: Generator<Yield = ()>> Future for GenFuture<T> {
38
type Output = T::Return;
39
fn poll(self: Pin<&mut Self>, lw: &LocalWaker) -> Poll<Self::Output> {
40
- set_task_waker(lw, || {
41
- match unsafe { Pin::get_unchecked_mut(self).0.resume() } {
42
- GeneratorState::Yielded(()) => Poll::Pending,
43
- GeneratorState::Complete(x) => Poll::Ready(x),
44
- }
+ // Safe because we're !Unpin + !Drop mapping to a ?Unpin value
+ let gen = unsafe { Pin::map_unchecked_mut(self, |s| &mut s.0) };
+ set_task_waker(lw, || match gen.resume() {
+ GeneratorState::Yielded(()) => Poll::Pending,
+ GeneratorState::Complete(x) => Poll::Ready(x),
45
})
46
}
47
0 commit comments