File tree Expand file tree Collapse file tree 4 files changed +48
-4
lines changed
futures-util/src/async_await Expand file tree Collapse file tree 4 files changed +48
-4
lines changed Original file line number Diff line number Diff line change 33/// This macro bakes in propagation of `Pending` signals by returning early.
44#[ macro_export]
55macro_rules! ready {
6- ( $e: expr) => ( match $e {
6+ ( $e: expr $ ( , ) ? ) => ( match $e {
77 $crate:: core_reexport:: task:: Poll :: Ready ( t) => t,
88 $crate:: core_reexport:: task:: Poll :: Pending =>
99 return $crate:: core_reexport:: task:: Poll :: Pending ,
Original file line number Diff line number Diff line change 2525/// ```
2626#[ macro_export]
2727macro_rules! join {
28- ( $( $fut: ident) ,* ) => { {
28+ ( $( $fut: ident) ,* $ ( , ) ? ) => { {
2929 $(
3030 // Move future into a local so that it is pinned in one place and
3131 // is no longer accessible by the end user.
@@ -91,7 +91,7 @@ macro_rules! join {
9191/// ```
9292#[ macro_export]
9393macro_rules! try_join {
94- ( $( $fut: ident) ,* ) => { {
94+ ( $( $fut: ident) ,* $ ( , ) ? ) => { {
9595 $(
9696 // Move future into a local so that it is pinned in one place and
9797 // is no longer accessible by the end user.
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ use futures_core::task::{Context, Poll};
1111/// _not_ activated by default.
1212#[ macro_export]
1313macro_rules! poll {
14- ( $x: expr) => {
14+ ( $x: expr $ ( , ) ? ) => {
1515 $crate:: async_await:: poll( $x) . await
1616 }
1717}
Original file line number Diff line number Diff line change 1+ #![ feature( async_await) ]
2+
3+ #[ macro_use]
4+ extern crate futures;
5+
6+ use futures:: {
7+ executor:: block_on,
8+ future:: { self , FutureExt } ,
9+ task:: Poll ,
10+ } ;
11+
12+ #[ test]
13+ fn ready ( ) {
14+ block_on ( future:: poll_fn ( |_| {
15+ ready ! ( Poll :: Ready ( ( ) ) , ) ;
16+ Poll :: Ready ( ( ) )
17+ } ) )
18+ }
19+
20+ #[ test]
21+ fn poll ( ) {
22+ block_on ( async {
23+ let _ = poll ! ( async { ( ) } . boxed( ) , ) ;
24+ } )
25+ }
26+
27+ #[ test]
28+ fn join ( ) {
29+ block_on ( async {
30+ let future1 = async { 1 } ;
31+ let future2 = async { 2 } ;
32+ join ! ( future1, future2, ) ;
33+ } )
34+ }
35+
36+ #[ test]
37+ fn try_join ( ) {
38+ block_on ( async {
39+ let future1 = async { 1 } . never_error ( ) ;
40+ let future2 = async { 2 } . never_error ( ) ;
41+ try_join ! ( future1, future2, )
42+ } )
43+ . unwrap ( ) ;
44+ }
You can’t perform that action at this time.
0 commit comments