Skip to content

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