fix(runtime-c-api) Replace unsafe code by safe code.

This commit is contained in:
Ivan Enderlin
2019-10-11 09:26:05 +02:00
parent 01c209fe96
commit c3ff8eb540

View File

@ -112,11 +112,13 @@ impl std::convert::TryFrom<u32> for wasmer_import_export_kind {
type Error = (); type Error = ();
fn try_from(value: u32) -> Result<Self, Self::Error> { fn try_from(value: u32) -> Result<Self, Self::Error> {
if value > 3 { Ok(match value {
Err(()) 0 => Self::WASM_FUNCTION,
} else { 1 => Self::WASM_GLOBAL,
Ok(unsafe { std::mem::transmute(value) }) 2 => Self::WASM_MEMORY,
} 3 => Self::WASM_TABLE,
_ => return Err(()),
})
} }
} }