-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//@ check-pass | ||
#![allow(dead_code)] | ||
|
||
use core::{ | ||
future::Future, | ||
pin::Pin, | ||
task::{Context, Poll, RawWaker, RawWakerVTable, Waker}, | ||
}; | ||
|
||
const NOP_RAWWAKER: RawWaker = { | ||
fn nop(_: *const ()) {} | ||
const VTAB: RawWakerVTable = RawWakerVTable::new(|_| NOP_RAWWAKER, nop, nop, nop); | ||
RawWaker::new(&() as *const (), &VTAB) | ||
}; | ||
|
||
const NOP_WAKER: &Waker = &unsafe { Waker::from_raw(NOP_RAWWAKER) }; | ||
|
||
const NOP_CONTEXT: Context<'static> = Context::from_waker(NOP_WAKER); | ||
|
||
fn poll_once<T, F>(f: &mut F) -> Poll<T> | ||
where | ||
F: Future<Output = T> + ?Sized + Unpin, | ||
{ | ||
let mut cx = NOP_CONTEXT; | ||
Pin::new(f).as_mut().poll(&mut cx) | ||
} | ||
|
||
fn main() {} |