Skip to content

Update to new stable futures #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/target
target/
**/*.rs.bk
Cargo.lock
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: rust
sudo: false
rust:
- nightly-2019-02-19
- nightly-2019-04-26

os:
- linux
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ edition = "2018"
pin-utils = "=0.1.0-alpha.4"

[dependencies.futures]
version = "=0.3.0-alpha.13"
version = "=0.3.0-alpha.15"
package = "futures-preview"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ like `FutureExt::map`, `TryFutureExt::and_then`...

# Requirements

Rust nightly-2019-02-19 for async_await, await_macro...
Rust nightly-2019-04-26 for async_await, await_macro...

# State

Expand Down
2 changes: 1 addition & 1 deletion examples/future.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(futures_api, async_await, await_macro)]
#![feature(async_await, await_macro)]

use futures_async_combinators::future::*;
use futures::executor;
Expand Down
2 changes: 1 addition & 1 deletion examples/stream.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(futures_api, async_await, await_macro)]
#![feature(async_await, await_macro)]

use futures_async_combinators::stream::*;
use futures::executor;
Expand Down
10 changes: 5 additions & 5 deletions src/future.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use futures::future::Future;
use futures::stream::Stream;

use core::task::{Poll, Waker};
use core::task::{Poll, Context};

pub async fn ready<T>(value: T) -> T {
value
Expand Down Expand Up @@ -140,15 +140,15 @@ pub fn into_stream<Fut>(future: Fut) -> impl Stream<Item = Fut::Output>
}

pub fn poll_fn<F, T>(f: F) -> impl Future<Output = T>
where F: FnMut(&Waker) -> Poll<T>,
where F: FnMut(&mut Context) -> Poll<T>,
{
use std::future::from_generator;
use std::future::get_task_waker;
use std::future::get_task_context;

from_generator(|| {
let mut f = f;
loop {
let poll_result = get_task_waker(|waker| f(waker));
let poll_result = get_task_context(|context: &mut Context| f(context));
match poll_result {
Poll::Pending => yield,
Poll::Ready(value) => return value,
Expand Down Expand Up @@ -288,7 +288,7 @@ mod tests {
#[test]
fn test_poll_fn() {
executor::block_on(async {
let read_line = |_waker: &_| -> Poll<String> {
let read_line = |_context: &mut Context| -> Poll<String> {
Poll::Ready("Hello, World!".into())
};

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(async_await, await_macro, futures_api, gen_future, generators)]
#![feature(async_await, await_macro, gen_future, generators)]

pub mod future;
pub mod stream;
2 changes: 1 addition & 1 deletion src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub async fn next<St>(stream: &mut St) -> Option<St::Item>
where St: Stream + Unpin,
{
use crate::future::poll_fn;
let future_next = poll_fn(|waker| Pin::new(&mut *stream).poll_next(waker));
let future_next = poll_fn(|context| Pin::new(&mut *stream).poll_next(context));
await!(future_next)
}

Expand Down