(self)
| 1689 | |
| 1690 | #[cfg(feature = "anyhow")] |
| 1691 | pub(crate) fn into_anyhow(self) -> anyhow::Error { |
| 1692 | if self.is_oom() { |
| 1693 | // Safety: `self.is_oom()` is true. |
| 1694 | anyhow::Error::from(unsafe { *self.unchecked_oom() }) |
| 1695 | } else { |
| 1696 | debug_assert!(self.is_boxed_dyn_error()); |
| 1697 | // Safety: this is a boxed dyn error. |
| 1698 | let ptr = unsafe { self.unchecked_into_dyn_error() }; |
| 1699 | // Safety: invariant of the type that the pointer is valid. |
| 1700 | let vtable = unsafe { ptr.as_ref().vtable }; |
| 1701 | // Safety: the pointer is valid and the vtable is associated with |
| 1702 | // this pointer's concrete error type. |
| 1703 | unsafe { (vtable.into_anyhow)(ptr) } |
| 1704 | } |
| 1705 | } |
| 1706 | |
| 1707 | fn source(&self) -> Option<&Error> { |
| 1708 | match self.unpack() { |
no test coverage detected