Implement std::fmt::Pointer for ExternRef (#4504)

This commit is contained in:
Nick Fitzgerald
2022-07-21 16:16:23 -07:00
committed by GitHub
parent b24c561ceb
commit 35b750ab9a
2 changed files with 12 additions and 0 deletions

View File

@@ -165,6 +165,12 @@ use wasmtime_environ::StackMap;
#[repr(transparent)]
pub struct VMExternRef(NonNull<VMExternData>);
impl std::fmt::Pointer for VMExternRef {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Pointer::fmt(&self.0, f)
}
}
// Data contained is always Send+Sync so these should be safe.
unsafe impl Send for VMExternRef {}
unsafe impl Sync for VMExternRef {}

View File

@@ -100,3 +100,9 @@ impl ExternRef {
externref_ptr as usize
}
}
impl std::fmt::Pointer for ExternRef {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Pointer::fmt(&self.inner, f)
}
}