>(e);
drop(unerased);
}
}
unsafe fn context_chain_is<C>(e: &ErrorImpl<()>, target: TypeId) -> bool
where
C: 'static,
{
if TypeId::of::<C>() == target {
true
} else {
let unerased = e as *const ErrorImpl<()> as *const ErrorImpl<ContextError<C, Error>>;
let source = &(*unerased)._error.error;
(source.inner.vtable.object_is)(&source.inner, target)
}
}
unsafe fn context_chain_downcast<C>(e: &ErrorImpl<()>, target: TypeId) -> Option<NonNull<()>>
where
C: 'static,
{
if TypeId::of::<C>() == target {
let unerased = e as *const ErrorImpl<()> as *const ErrorImpl<ContextError<C, Error>>;
let addr = &(*unerased)._error.context as *const C as *mut ();
Some(NonNull::new_unchecked(addr))
} else {
let unerased = e as *const ErrorImpl<()> as *const ErrorImpl<ContextError<C, Error>>;
let source = &(*unerased)._error.error;
(source.inner.vtable.object_downcast)(&source.inner, target)
}
}
unsafe fn context_chain_drop_rest<C>(e: Box<ErrorImpl<()>>, target: TypeId)
where
C: 'static,
{
// Called after downcasting by value to either the C or one of the causes
// and doing a ptr::read to take ownership of that value.
if TypeId::of::<C>() == target {
let unerased = mem::transmute::<
Box<ErrorImpl<()>>,
Box<ErrorImpl<ContextError<ManuallyDrop<C>, Error>>>,