File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -88,4 +88,38 @@ async fn async_main() {
88
88
} ;
89
89
call_once ( c) . await ;
90
90
}
91
+
92
+ fn force_fnonce < T > ( f : impl async FnOnce ( ) -> T ) -> impl async FnOnce ( ) -> T {
93
+ f
94
+ }
95
+
96
+ // Capture something with `move`, but infer to `AsyncFnOnce`
97
+ {
98
+ let x = Hello ( 6 ) ;
99
+ let c = force_fnonce ( async move || {
100
+ println ! ( "{x:?}" ) ;
101
+ } ) ;
102
+ call_once ( c) . await ;
103
+
104
+ let x = & Hello ( 7 ) ;
105
+ let c = force_fnonce ( async move || {
106
+ println ! ( "{x:?}" ) ;
107
+ } ) ;
108
+ call_once ( c) . await ;
109
+ }
110
+
111
+ // Capture something by-ref, but infer to `AsyncFnOnce`
112
+ {
113
+ let x = Hello ( 8 ) ;
114
+ let c = force_fnonce ( async || {
115
+ println ! ( "{x:?}" ) ;
116
+ } ) ;
117
+ call_once ( c) . await ;
118
+
119
+ let x = & Hello ( 9 ) ;
120
+ let c = force_fnonce ( async || {
121
+ println ! ( "{x:?}" ) ;
122
+ } ) ;
123
+ call_once ( c) . await ;
124
+ }
91
125
}
Original file line number Diff line number Diff line change 8
8
Hello(4)
9
9
Hello(4)
10
10
Hello(5)
11
+ Hello(6)
12
+ Hello(7)
13
+ Hello(8)
14
+ Hello(9)
You can’t perform that action at this time.
0 commit comments