]> git.lizzy.rs Git - rust.git/commit - src/tools/rust-analyzer
Rollup merge of #89651 - ibraheemdev:poll-ready, r=dtolnay
authorMatthias Krüger <matthias.krueger@famsik.de>
Mon, 11 Oct 2021 21:45:48 +0000 (23:45 +0200)
committerGitHub <noreply@github.com>
Mon, 11 Oct 2021 21:45:48 +0000 (23:45 +0200)
commitd3984e16bf04f8ff886247cbf684041ba623d6ab
treeeb817a52bc1a0e32928a75aea5d02e170ed5b303
parentb80dd9e445e19fd82d305cd61cd266b0ee61bfee
parenta1e03fc563eaaab04b747cf8d3f1a0d8931e39fd
Rollup merge of #89651 - ibraheemdev:poll-ready, r=dtolnay

Add `Poll::ready` and revert stabilization of `task::ready!`

This PR adds an inherent `ready` method to `Poll` that can be used with the `?` operator as an alternative to the `task::ready!` macro:
```rust
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:

```rust
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