File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change 3
3
// edition:2018
4
4
// aux-build:arc_wake.rs
5
5
6
- #![ feature( async_await) ]
6
+ #![ feature( async_await, async_closure ) ]
7
7
8
8
extern crate arc_wake;
9
9
@@ -70,6 +70,13 @@ fn async_nonmove_block(x: u8) -> impl Future<Output = u8> {
70
70
}
71
71
}
72
72
73
+ fn async_closure ( x : u8 ) -> impl Future < Output = u8 > {
74
+ ( async move |x : u8 | -> u8 {
75
+ wake_and_yield_once ( ) . await ;
76
+ x
77
+ } ) ( x)
78
+ }
79
+
73
80
async fn async_fn ( x : u8 ) -> u8 {
74
81
wake_and_yield_once ( ) . await ;
75
82
x
@@ -173,6 +180,7 @@ fn main() {
173
180
test ! {
174
181
async_block,
175
182
async_nonmove_block,
183
+ async_closure,
176
184
async_fn,
177
185
generic_async_fn,
178
186
async_fn_with_internal_borrow,
Original file line number Diff line number Diff line change @@ -134,11 +134,15 @@ trait Bar {
134
134
}
135
135
136
136
impl Foo {
137
- async fn async_method ( x : u8 ) -> u8 {
137
+ async fn async_assoc_item ( x : u8 ) -> u8 {
138
138
unsafe {
139
139
await ! ( unsafe_async_fn( x) )
140
140
}
141
141
}
142
+
143
+ async unsafe fn async_unsafe_assoc_item ( x : u8 ) -> u8 {
144
+ await ! ( unsafe_async_fn( x) )
145
+ }
142
146
}
143
147
144
148
fn test_future_yields_once_then_returns < F , Fut > ( f : F )
@@ -180,12 +184,17 @@ fn main() {
180
184
async_fn,
181
185
generic_async_fn,
182
186
async_fn_with_internal_borrow,
183
- Foo :: async_method ,
187
+ Foo :: async_assoc_item ,
184
188
|x| {
185
189
async move {
186
190
unsafe { await !( unsafe_async_fn( x) ) }
187
191
}
188
192
} ,
193
+ |x| {
194
+ async move {
195
+ unsafe { await !( Foo :: async_unsafe_assoc_item( x) ) }
196
+ }
197
+ } ,
189
198
}
190
199
test_with_borrow ! {
191
200
async_block_with_borrow_named_lifetime,
You can’t perform that action at this time.
0 commit comments