Skip to content

Commit

Permalink
implement drop instead of manual destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed May 21, 2022
1 parent 694251e commit f7b6b27
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions bindings/rust/evmc-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ pub struct EvmcVm {
host_interface: *mut ffi::evmc_host_interface,
}

impl Drop for EvmcVm {
fn drop(&mut self) {
debug_assert!(!self.handle.is_null());
unsafe { ((*self.handle).destroy.unwrap())(self.handle) }
}
}

impl EvmcVm {
pub fn get_abi_version(&self) -> i32 {
unsafe {
Expand All @@ -39,10 +46,6 @@ impl EvmcVm {
}
}

pub fn destroy(&self) {
unsafe { ((*self.handle).destroy.unwrap())(self.handle) }
}

pub fn execute(
&self,
ctx: &mut dyn host::HostContext,
Expand Down

0 comments on commit f7b6b27

Please sign in to comment.