File tree 2 files changed +24
-0
lines changed
2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -608,6 +608,10 @@ macro_rules! select {
608
608
609
609
// ===== Entry point =====
610
610
611
+ ( $( biased; ) ? else => $else: expr $( , ) ? ) => { {
612
+ $else
613
+ } } ;
614
+
611
615
( biased; $p: pat = $( $t: tt) * ) => {
612
616
$crate:: select!( @{ start=0 ; ( ) } $p = $( $t) * )
613
617
} ;
@@ -617,6 +621,7 @@ macro_rules! select {
617
621
// fair and avoids always polling the first future.
618
622
$crate:: select!( @{ start={ $crate:: macros:: support:: thread_rng_n( BRANCHES ) } ; ( ) } $p = $( $t) * )
619
623
} ;
624
+
620
625
( ) => {
621
626
compile_error!( "select! requires at least one branch." )
622
627
} ;
Original file line number Diff line number Diff line change @@ -22,6 +22,25 @@ async fn sync_one_lit_expr_comma() {
22
22
assert_eq ! ( foo, 1 ) ;
23
23
}
24
24
25
+ #[ maybe_tokio_test]
26
+ async fn no_branch_else_only ( ) {
27
+ let foo = tokio:: select! {
28
+ else => 1 ,
29
+ } ;
30
+
31
+ assert_eq ! ( foo, 1 ) ;
32
+ }
33
+
34
+ #[ maybe_tokio_test]
35
+ async fn no_branch_else_only_biased ( ) {
36
+ let foo = tokio:: select! {
37
+ biased;
38
+ else => 1 ,
39
+ } ;
40
+
41
+ assert_eq ! ( foo, 1 ) ;
42
+ }
43
+
25
44
#[ maybe_tokio_test]
26
45
async fn nested_one ( ) {
27
46
let foo = tokio:: select! {
You can’t perform that action at this time.
0 commit comments