MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / into_boxed_dyn_core_error

Method into_boxed_dyn_core_error

crates/core/src/error/error.rs:1670–1688  ·  view source on GitHub ↗
(
        self,
    )

Source from the content-addressed store, hash-verified

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 {

Callers 1

into_boxed_dyn_errorMethod · 0.80

Calls 6

OkFunction · 0.85
unchecked_oomMethod · 0.80
writeFunction · 0.50
is_oomMethod · 0.45
as_refMethod · 0.45

Tested by

no test coverage detected