pub trait CancelSignal: Sync {
fn is_cancelled(&self) -> bool;
}
impl<F> CancelSignal for F
where
F: Fn() -> bool + Sync,
{
fn is_cancelled(&self) -> bool {
self()
}
}
#[derive(Clone, Copy, Debug, Default)]
pub struct NeverCancelled;
impl CancelSignal for NeverCancelled {
fn is_cancelled(&self) -> bool {
false
}
}