use std::error::Error;
pub struct Canceled {
_private: (),
}
impl Canceled {
fn new() -> Self {
Canceled { _private: () }
}
pub fn throw() -> ! {
std::panic::resume_unwind(Box::new(Canceled::new()))
}
}
impl std::fmt::Display for Canceled {
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fmt.write_str("canceled")
}
}
impl std::fmt::Debug for Canceled {
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(fmt, "Canceled")
}
}
impl std::error::Error for Canceled {}
pub(crate) fn is_canceled(e: &(dyn Error + 'static)) -> bool {
e.downcast_ref::<Canceled>().is_some()
}