(
self,
)
| 1668 | } |
| 1669 | |
| 1670 | pub(crate) fn into_boxed_dyn_core_error( |
| 1671 | self, |
| 1672 | ) -> Result<Box<dyn core::error::Error + Send + Sync + 'static>, OutOfMemory> { |
| 1673 | if self.is_oom() { |
| 1674 | let boxed = try_new_uninit_box::<OutOfMemory>()?; |
| 1675 | // Safety: `self.is_oom()` is true. |
| 1676 | let boxed = Box::write(boxed, unsafe { *self.unchecked_oom() }); |
| 1677 | Ok(boxed as _) |
| 1678 | } else { |
| 1679 | debug_assert!(self.is_boxed_dyn_error()); |
| 1680 | // Safety: this is a boxed dyn error. |
| 1681 | let ptr = unsafe { self.unchecked_into_dyn_error() }; |
| 1682 | // Safety: invariant of the type that the pointer is valid. |
| 1683 | let vtable = unsafe { ptr.as_ref().vtable }; |
| 1684 | // Safety: the pointer is valid and the vtable is associated with |
| 1685 | // this pointer's concrete error type. |
| 1686 | unsafe { (vtable.into_boxed_dyn_core_error)(ptr) } |
| 1687 | } |
| 1688 | } |
| 1689 | |
| 1690 | #[cfg(feature = "anyhow")] |
| 1691 | pub(crate) fn into_anyhow(self) -> anyhow::Error { |
no test coverage detected