2022-11-24 02:36:46 +00:00
|
|
|
// run-pass
|
2022-11-19 03:06:21 +00:00
|
|
|
// edition:2021
|
2022-11-24 02:36:46 +00:00
|
|
|
// check-run-results
|
2022-11-19 03:06:21 +00:00
|
|
|
|
|
|
|
#![feature(dyn_star)]
|
|
|
|
//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes
|
2023-12-14 18:34:29 +00:00
|
|
|
#![feature(noop_waker)]
|
2022-11-19 03:06:21 +00:00
|
|
|
|
|
|
|
use std::future::Future;
|
|
|
|
|
|
|
|
async fn foo(f: dyn* Future<Output = i32>) {
|
|
|
|
println!("value: {}", f.await);
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn async_main() {
|
|
|
|
foo(Box::pin(async { 1 })).await
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------- //
|
|
|
|
// Implementation Details Below...
|
|
|
|
|
2023-12-14 18:34:29 +00:00
|
|
|
use std::pin::pin;
|
2024-01-14 16:25:43 -08:00
|
|
|
use std::task::*;
|
2022-11-19 03:06:21 +00:00
|
|
|
|
|
|
|
fn main() {
|
2023-12-14 18:34:29 +00:00
|
|
|
let mut fut = pin!(async_main());
|
2022-11-19 03:06:21 +00:00
|
|
|
|
|
|
|
// Poll loop, just to test the future...
|
2024-01-14 16:25:43 -08:00
|
|
|
let ctx = &mut Context::from_waker(Waker::noop());
|
2022-11-19 03:06:21 +00:00
|
|
|
|
|
|
|
loop {
|
2023-12-14 18:34:29 +00:00
|
|
|
match fut.as_mut().poll(ctx) {
|
2022-11-19 03:06:21 +00:00
|
|
|
Poll::Pending => {}
|
|
|
|
Poll::Ready(()) => break,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|