use core::mem;
use core::ptr;
use core::task;
#[cfg(feature = "std")]
pub(crate) fn abort() -> ! {
std::process::abort()
}
#[cfg(not(feature = "std"))]
pub(crate) fn abort() -> ! {
loop {}
}
#[cfg(feature = "alloc")]
pub(crate) fn checked_increment(value: usize) -> usize {
if value == usize::MAX {
abort()
}
value + 1
}
pub fn noop_cx() -> task::Context<'static> {
const VTABLE: task::RawWakerVTable = task::RawWakerVTable::new(
|_| RAW,
|_| {},
|_| {},
|_| {},
);
const RAW: task::RawWaker = task::RawWaker::new(ptr::null(), &VTABLE);
static WAKER: task::Waker = unsafe { mem::transmute::<task::RawWaker, task::Waker>(RAW) };
task::Context::from_waker(&WAKER)
}