Commit a32ea8e
futures-util: Added FutureExt::now_or_never() (#1747)
`now_or_never()` is a convenience method for `FutureExt` that
evaluates and consumes the future, returning the resulting output if
the future is ready after the first call to `Future::poll`. If `poll`
instead returns `Poll::Pending`, `None` is returned.
This method is useful in cases where immediacy is more important than
waiting for a result. It is also convenient for quickly obtaining the
value of a future that is known to always resolve immediately.
It is named after the english phrase "It's *now or never*", which the
Macmillan Dictionary defines[¹] as such:
> used for saying that if something is not done immediately, there
> will not be another chance to do it in the future
[¹]: https://www.macmillandictionary.com/us/dictionary/american/it-s-now-or-never1 parent 7136a1e commit a32ea8e
1 file changed
+48
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
531 | 531 | | |
532 | 532 | | |
533 | 533 | | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
534 | 582 | | |
535 | 583 | | |
536 | 584 | | |
| |||
0 commit comments