diff --git a/src/host.rs b/src/host.rs index 3b3af5b..a15fd9d 100644 --- a/src/host.rs +++ b/src/host.rs @@ -29,7 +29,7 @@ impl<'a> RuntimeArgs<'a> { /// Returns `Err` if this list has not enough arguments. pub fn nth_value_checked(&self, idx: usize) -> Result { if self.0.len() <= idx { - return Err(Trap::new(TrapKind::UnexpectedSignature)); + return Err(TrapKind::UnexpectedSignature.into()); } Ok(self.0[idx]) } @@ -207,7 +207,7 @@ impl Externals for NopExternals { _index: usize, _args: RuntimeArgs, ) -> Result, Trap> { - Err(Trap::new(TrapKind::Unreachable)) + Err(TrapKind::Unreachable.into()) } } diff --git a/src/tests/host.rs b/src/tests/host.rs index 43d03ae..a6546b9 100644 --- a/src/tests/host.rs +++ b/src/tests/host.rs @@ -92,7 +92,7 @@ impl Externals for TestHost { ERR_FUNC_INDEX => { let error_code: u32 = args.nth(0); let error = HostErrorWithCode { error_code }; - Err(Trap::new(TrapKind::Host(Box::new(error)))) + Err(TrapKind::Host(Box::new(error)).into()) } INC_MEM_FUNC_INDEX => { let ptr: u32 = args.nth(0); @@ -131,7 +131,7 @@ impl Externals for TestHost { .expect("expected to be Some"); if val.value_type() != result.value_type() { - return Err(Trap::new(TrapKind::Host(Box::new(HostErrorWithCode { error_code: 123 })))); + return Err(TrapKind::Host(Box::new(HostErrorWithCode { error_code: 123 })).into()); } Ok(Some(result)) }