1
Fork 0

Made from_waker, waker, from_raw const

This commit is contained in:
y86-dev 2022-09-14 14:15:44 +02:00
parent c97922dca5
commit 9a78faba71
6 changed files with 26 additions and 4 deletions

View file

@ -1,4 +1,4 @@
use core::task::Poll;
use core::task::{Context, Poll, RawWaker, RawWakerVTable, Waker};
#[test]
fn poll_const() {
@ -12,3 +12,18 @@ fn poll_const() {
const IS_PENDING: bool = POLL.is_pending();
assert!(IS_PENDING);
}
#[test]
fn waker_const() {
const VOID_TABLE: RawWakerVTable = RawWakerVTable::new(|_| VOID_WAKER, |_| {}, |_| {}, |_| {});
const VOID_WAKER: RawWaker = RawWaker::new(&(), &VOID_TABLE);
static WAKER: Waker = unsafe { Waker::from_raw(VOID_WAKER) };
static CONTEXT: Context<'static> = Context::from_waker(&WAKER);
static WAKER_REF: &'static Waker = CONTEXT.waker();
WAKER_REF.wake_by_ref();
}