diff --git a/lib/c-api/src/wasm_c_api/types/function.rs b/lib/c-api/src/wasm_c_api/types/function.rs index cf8cfeaa347..2d8a5d163d7 100644 --- a/lib/c-api/src/wasm_c_api/types/function.rs +++ b/lib/c-api/src/wasm_c_api/types/function.rs @@ -1,7 +1,4 @@ -use super::{ - wasm_externtype_t, wasm_valtype_t, wasm_valtype_vec_delete, wasm_valtype_vec_t, WasmExternType, -}; -use std::mem; +use super::{wasm_externtype_t, wasm_valtype_vec_delete, wasm_valtype_vec_t, WasmExternType}; use wasmer::{ExternType, FunctionType, ValType}; #[derive(Debug)] @@ -13,44 +10,8 @@ pub(crate) struct WasmFunctionType { impl WasmFunctionType { pub(crate) fn new(function_type: FunctionType) -> Self { - let params = { - let mut valtypes = function_type - .params() - .iter() - .cloned() - .map(Into::into) - .map(Box::new) - .map(Box::into_raw) - .collect::>(); - - let valtypes_vec = Box::new(wasm_valtype_vec_t { - size: valtypes.len(), - data: valtypes.as_mut_ptr(), - }); - - mem::forget(valtypes); - - valtypes_vec - }; - let results = { - let mut valtypes = function_type - .results() - .iter() - .cloned() - .map(Into::into) - .map(Box::new) - .map(Box::into_raw) - .collect::>(); - - let valtypes_vec = Box::new(wasm_valtype_vec_t { - size: valtypes.len(), - data: valtypes.as_mut_ptr(), - }); - - mem::forget(valtypes); - - valtypes_vec - }; + let params: Box = Box::new(function_type.params().into()); + let results: Box = Box::new(function_type.results().into()); Self { function_type,