mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-27 07:31:33 +00:00
fix(runtime-c-api) Replace unsafe code by safe code.
This commit is contained in:
@ -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(()),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user