Skip to content
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

Expose task::Context to lazy #878

Merged
merged 1 commit into from
Mar 19, 2018
Merged

Expose task::Context to lazy #878

merged 1 commit into from
Mar 19, 2018

Conversation

srijs
Copy link
Contributor

@srijs srijs commented Mar 18, 2018

I'm currently working on moving the hyper 0.12.x branch over to the futures 0.2 alpha release.

As part of this, I'm starting to notice a few places where I would like to get hold of task::Context without needing to write a special future for it.

Here is an example:

fut.and_then(move |res| {
    // how do I get access to `cx`?
    if let Ok(Async::Pending) = pooled.tx.poll_ready(cx) {
        // do stuff
    }

    Ok(Async::Ready(res))
});

I tried using poll_fn, since that gives me the task::Context as an argument, but since it has a FnMut it doesn't work for most of cases I've tried.

Therefore I would like to propose this change, introducing task::Context as an argument to the closure passed in to lazy, similar to how it works for poll_fn.

Let me know what you think!

@cramertj
Copy link
Member

Thanks for the PR! This makes sense to me.

@cramertj cramertj merged commit c14f058 into rust-lang:master Mar 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants