diff --git a/src/func.rs b/src/func.rs index f887195..b72107d 100644 --- a/src/func.rs +++ b/src/func.rs @@ -141,7 +141,7 @@ impl FuncInstance { args: &[RuntimeValue], externals: &mut E, ) -> Result, Trap> { - check_function_args(func.signature(), &args).map_err(|_| Trap::new(TrapKind::UnexpectedSignature))?; + check_function_args(func.signature(), &args).map_err(|_| TrapKind::UnexpectedSignature)?; match *func.as_internal() { FuncInstanceInternal::Internal { .. } => { let mut interpreter = Interpreter::new(externals); diff --git a/src/host.rs b/src/host.rs index 580be3c..3b3af5b 100644 --- a/src/host.rs +++ b/src/host.rs @@ -19,7 +19,7 @@ impl<'a> RuntimeArgs<'a> { /// /// Returns `Err` if cast is invalid or not enough arguments. pub fn nth_checked(&self, idx: usize) -> Result where RuntimeValue: TryInto { - Ok(self.nth_value_checked(idx)?.try_into().map_err(|_| Trap::new(TrapKind::UnexpectedSignature))?) + Ok(self.nth_value_checked(idx)?.try_into().map_err(|_| TrapKind::UnexpectedSignature)?) } /// Extract argument as a [`RuntimeValue`] by index `idx`. diff --git a/src/lib.rs b/src/lib.rs index dc1aed3..7d69caf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -316,6 +316,12 @@ impl From for Error { } } +impl From for Trap { + fn from(e: TrapKind) -> Trap { + Trap::new(e) + } +} + impl From for Error { fn from(e: validation::Error) -> Error { Error::Validation(e.to_string()) diff --git a/src/tests/host.rs b/src/tests/host.rs index ad00dc1..43d03ae 100644 --- a/src/tests/host.rs +++ b/src/tests/host.rs @@ -652,7 +652,7 @@ fn dynamically_add_host_func() { host_func_index as usize, ); self.table.set(table_index, Some(added_func)) - .map_err(|_| Trap::new(TrapKind::TableAccessOutOfBounds))?; + .map_err(|_| TrapKind::TableAccessOutOfBounds)?; Ok(Some(RuntimeValue::I32(table_index as i32))) }