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 3
3
/// This macro bakes in propagation of `Pending` signals by returning early.
4
4
#[ macro_export]
5
5
macro_rules! ready {
6
- ( $e: expr) => ( match $e {
6
+ ( $e: expr $ ( , ) ? ) => ( match $e {
7
7
$crate:: core_reexport:: task:: Poll :: Ready ( t) => t,
8
8
$crate:: core_reexport:: task:: Poll :: Pending =>
9
9
return $crate:: core_reexport:: task:: Poll :: Pending ,
Original file line number Diff line number Diff line change 25
25
/// ```
26
26
#[ macro_export]
27
27
macro_rules! join {
28
- ( $( $fut: ident) ,* ) => { {
28
+ ( $( $fut: ident) ,* $ ( , ) ? ) => { {
29
29
$(
30
30
// Move future into a local so that it is pinned in one place and
31
31
// is no longer accessible by the end user.
@@ -91,7 +91,7 @@ macro_rules! join {
91
91
/// ```
92
92
#[ macro_export]
93
93
macro_rules! try_join {
94
- ( $( $fut: ident) ,* ) => { {
94
+ ( $( $fut: ident) ,* $ ( , ) ? ) => { {
95
95
$(
96
96
// Move future into a local so that it is pinned in one place and
97
97
// 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};
11
11
/// _not_ activated by default.
12
12
#[ macro_export]
13
13
macro_rules! poll {
14
- ( $x: expr) => {
14
+ ( $x: expr $ ( , ) ? ) => {
15
15
$crate:: async_await:: poll( $x) . await
16
16
}
17
17
}
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