Tweak the API of the Val type (#679)
* Tweak the API of the `Val` type A few updates to the API of the `Val` type: * Added a payload for `V128`. * Replace existing accessor methods with `Option`-returning versions. * Add `unwrap_xxx` family of methods to extract a value and panic. * Remove `Into` conversions which panic, since panicking in `From` or `Into` isn't idiomatic in Rust * Add documentation to all methods/values/enums/etc. * Rename `Val::default` to `Val::null` * Run rustfmt * Review comments
This commit is contained in:
@@ -152,7 +152,14 @@ impl ModuleData {
|
||||
Ok(values) => values
|
||||
.to_vec()
|
||||
.into_iter()
|
||||
.map(|v: wasmtime::Val| v.into())
|
||||
.map(|v: wasmtime::Val| match v {
|
||||
wasmtime::Val::I32(i) => RuntimeValue::I32(i),
|
||||
wasmtime::Val::I64(i) => RuntimeValue::I64(i),
|
||||
wasmtime::Val::F32(i) => RuntimeValue::F32(i),
|
||||
wasmtime::Val::F64(i) => RuntimeValue::F64(i),
|
||||
wasmtime::Val::V128(i) => RuntimeValue::V128(i),
|
||||
_ => panic!("unsupported value {:?}", v),
|
||||
})
|
||||
.collect::<Vec<RuntimeValue>>(),
|
||||
Err(trap) => bail!("trapped: {:?}", trap),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user