diff --git a/lib/c-api/src/wasm_c_api/types/value.rs b/lib/c-api/src/wasm_c_api/types/value.rs index 542833638..023539c36 100644 --- a/lib/c-api/src/wasm_c_api/types/value.rs +++ b/lib/c-api/src/wasm_c_api/types/value.rs @@ -1,5 +1,6 @@ use super::super::value::wasm_valkind_t; use std::convert::TryInto; +use std::ptr::NonNull; use wasmer::ValType; #[allow(non_camel_case_types)] @@ -83,10 +84,11 @@ pub extern "C" fn wasm_valtype_new(kind: wasm_valkind_t) -> Option>) {} #[no_mangle] -pub unsafe extern "C" fn wasm_valtype_kind(valtype: *const wasm_valtype_t) -> wasm_valkind_t { - if valtype.is_null() { - // TODO: handle error - panic!("wasm_valtype_kind: argument is null pointer"); - } - return (*valtype).valkind as wasm_valkind_t; +pub unsafe extern "C" fn wasm_valtype_kind( + valtype: Option>, +) -> wasm_valkind_t { + valtype + .expect("`wasm_valtype_kind: argument is a null pointer") + .as_ref() + .valkind as wasm_valkind_t }