use core::{
cell::{BorrowError, BorrowMutError},
error::Error,
fmt::{self, Display, Formatter},
};
#[derive(Debug)]
pub enum AnyFnError {
Borrow(BorrowError),
BorrowMut(BorrowMutError),
Downcast,
}
impl From<BorrowError> for AnyFnError {
fn from(error: BorrowError) -> Self {
Self::Borrow(error)
}
}
impl From<BorrowMutError> for AnyFnError {
fn from(error: BorrowMutError) -> Self {
Self::BorrowMut(error)
}
}
impl Error for AnyFnError {}
impl Display for AnyFnError {
fn fmt(&self, formatter: &mut Formatter) -> fmt::Result {
match self {
Self::Downcast => write!(formatter, "cannot downcast object"),
Self::Borrow(error) => write!(formatter, "{error}"),
Self::BorrowMut(error) => write!(formatter, "{error}"),
}
}
}