Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Commit

Permalink
Fix breakage caused by nightly-2019-01-29
Browse files Browse the repository at this point in the history
  • Loading branch information
vorot93 committed Jan 29, 2019
1 parent ec0874d commit 8b18122
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ pub mod prelude {
#[doc(hidden)]
pub mod __rt {
pub extern crate std;
pub use std::ops::Generator;

use core::{
marker::{PhantomData, Unpin},
ops::{Generator, GeneratorState},
pin::Pin,
};
use futures::Poll;
use futures::{Async, Future, Stream};
use std::marker::PhantomData;
use std::ops::GeneratorState;

pub trait MyFuture<T: IsResult>: Future<Item = T::Ok, Error = T::Err> {}

Expand Down Expand Up @@ -76,7 +77,7 @@ pub mod __rt {
type Ok = T;
type Err = E;

fn into_result(self) -> Result<Self::Ok, Self::Err> {
fn into_result(self) -> Result<T, E> {
self
}
}
Expand Down Expand Up @@ -104,15 +105,15 @@ pub mod __rt {

pub fn gen<T>(gen: T) -> impl MyFuture<T::Return>
where
T: Generator<Yield = Async<Mu>>,
T: Generator<Yield = Async<Mu>> + Unpin,
T::Return: IsResult,
{
GenFuture(gen)
}

pub fn gen_stream<T, U>(gen: T) -> impl MyStream<U, T::Return>
where
T: Generator<Yield = Async<U>>,
T: Generator<Yield = Async<U>> + Unpin,
T::Return: IsResult<Ok = ()>,
{
GenStream {
Expand All @@ -124,14 +125,14 @@ pub mod __rt {

impl<T> Future for GenFuture<T>
where
T: Generator<Yield = Async<Mu>>,
T: Generator<Yield = Async<Mu>> + Unpin,
T::Return: IsResult,
{
type Item = <T::Return as IsResult>::Ok;
type Error = <T::Return as IsResult>::Err;

fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
match unsafe { self.0.resume() } {
match Pin::new(&mut self.0).resume() {
GeneratorState::Yielded(Async::NotReady) => Ok(Async::NotReady),
GeneratorState::Yielded(Async::Ready(mu)) => match mu {},
GeneratorState::Complete(e) => e.into_result().map(Async::Ready),
Expand All @@ -141,7 +142,7 @@ pub mod __rt {

impl<U, T> Stream for GenStream<U, T>
where
T: Generator<Yield = Async<U>>,
T: Generator<Yield = Async<U>> + Unpin,
T::Return: IsResult<Ok = ()>,
{
type Item = U;
Expand All @@ -151,7 +152,7 @@ pub mod __rt {
if self.done {
return Ok(Async::Ready(None));
}
match unsafe { self.gen.resume() } {
match Pin::new(&mut self.gen).resume() {
GeneratorState::Yielded(Async::Ready(e)) => Ok(Async::Ready(Some(e))),
GeneratorState::Yielded(Async::NotReady) => Ok(Async::NotReady),
GeneratorState::Complete(e) => {
Expand Down

0 comments on commit 8b18122

Please # to comment.