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