7 use std::{future::Future, pin::Pin, task::Poll, ptr};
8 use std::task::{Waker, RawWaker, RawWakerVTable, Context};
10 // See if we can run a basic `async fn`
11 pub async fn foo(x: &u32, y: u32) -> u32 {
15 let y = await!(async { *y + *z });
21 fn raw_waker_clone(_this: *const ()) -> RawWaker {
22 panic!("unimplemented");
24 fn raw_waker_wake(_this: *const ()) {
25 panic!("unimplemented");
27 fn raw_waker_wake_by_ref(_this: *const ()) {
28 panic!("unimplemented");
30 fn raw_waker_drop(_this: *const ()) {}
32 static RAW_WAKER: RawWakerVTable = RawWakerVTable::new(
35 raw_waker_wake_by_ref,
41 let mut fut = foo(&x, 7);
42 let waker = unsafe { Waker::from_raw(RawWaker::new(ptr::null(), &RAW_WAKER)) };
43 let mut context = Context::from_waker(&waker);
44 assert_eq!(unsafe { Pin::new_unchecked(&mut fut) }.poll(&mut context), Poll::Ready(31));