Skip to content
This repository was archived by the owner on Apr 8, 2026. It is now read-only.

Commit f7b6b27

Browse files
committed
implement drop instead of manual destroy
1 parent 694251e commit f7b6b27

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

  • bindings/rust/evmc-client/src

bindings/rust/evmc-client/src/lib.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ pub struct EvmcVm {
1717
host_interface: *mut ffi::evmc_host_interface,
1818
}
1919

20+
impl Drop for EvmcVm {
21+
fn drop(&mut self) {
22+
debug_assert!(!self.handle.is_null());
23+
unsafe { ((*self.handle).destroy.unwrap())(self.handle) }
24+
}
25+
}
26+
2027
impl EvmcVm {
2128
pub fn get_abi_version(&self) -> i32 {
2229
unsafe {
@@ -39,10 +46,6 @@ impl EvmcVm {
3946
}
4047
}
4148

42-
pub fn destroy(&self) {
43-
unsafe { ((*self.handle).destroy.unwrap())(self.handle) }
44-
}
45-
4649
pub fn execute(
4750
&self,
4851
ctx: &mut dyn host::HostContext,

0 commit comments

Comments
 (0)