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

Implement core::future::lazy #91648

Closed
wants to merge 1 commit into from

Conversation

ibraheemdev
Copy link
Member

@ibraheemdev ibraheemdev commented Dec 8, 2021

Lazy executes a closure the first time it is polled:

let a = std::future::lazy(|_| 1);
assert_eq!(a.await, 1);

Prior art: https://docs.rs/futures/latest/futures/future/fn.lazy.html

The argument for exposing task::Context to the closure is that lazy can serve as a one-time poll_fn that accepts an FnOnce, as opposed to an FnMut. See here for details.

(Would a better name be once?)

@rust-highfive
Copy link
Collaborator

r? @joshtriplett

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 8, 2021
@ibraheemdev ibraheemdev mentioned this pull request Dec 8, 2021
3 tasks
@bors
Copy link
Contributor

bors commented Dec 9, 2021

☔ The latest upstream changes (presumably #91691) made this pull request unmergeable. Please resolve the merge conflicts.

@apiraino apiraino added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Dec 9, 2021
@dtolnay dtolnay added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Dec 10, 2021
@JohnCSimon JohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 6, 2022
@JohnCSimon JohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 6, 2022
@JohnCSimon JohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 11, 2022
@JohnCSimon JohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 8, 2022
@JohnCSimon
Copy link
Member

Triage: merge conflicts

@JohnCSimon
Copy link
Member

@ibraheemdev can you please resolve the merge conflicts?

@JohnCSimon JohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 24, 2022
@JohnCSimon
Copy link
Member

Ping from triage:
@joshtriplett - what is the status of reviewing this PR? Thanks.

@thomcc
Copy link
Member

thomcc commented Oct 23, 2022

@ibraheemdev Mind making an ACP for this.

r=me on the impl if the API gets a second.

r? @thomcc

@rust-highfive rust-highfive assigned thomcc and unassigned joshtriplett Oct 23, 2022
@thomcc
Copy link
Member

thomcc commented Oct 23, 2022

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 23, 2022
@ibraheemdev
Copy link
Member Author

ibraheemdev commented Dec 2, 2022

After thinking about it, I'm not sure there's any benefit of this over an async block and something like #92116 (comment) to access the context. I'm going to close this for now.

@ibraheemdev ibraheemdev closed this Dec 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants