3

Add `Poll::ready` and revert stabilization of `task::ready!` by ibraheemdev · Pu...

 2 years ago
source link: https://github.com/rust-lang/rust/pull/89651
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Copy link

Contributor

ibraheemdev commented 22 days ago

edited

This PR adds an inherent ready method to Poll that can be used with the ? operator as an alternative to the task::ready! macro:

let val = ready!(fut.poll(cx));
let val = fut.poll(cx).ready()?;

I think this form is a nice, non-breaking middle ground between changing the impl Try for Poll, and adding a separate macro. It looks better than ready! in my opinion, and it composes well:

let elem = ready!(fut.poll(cx)).pop().unwrap();
let elem = fut.poll(cx).ready()?.pop().unwrap();

The planned stabilization of ready! in 1.56 has been reverted because I think this alternate approach is worth considering.

r? rust-lang/libs


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK