Use .into() to convert TrapKind into Trap

This commit is contained in:
Sergey Pepyakin 2018-02-06 13:57:15 +03:00
parent 2c2cb72078
commit 2b880b1e18
2 changed files with 4 additions and 4 deletions

View File

@ -29,7 +29,7 @@ impl<'a> RuntimeArgs<'a> {
/// Returns `Err` if this list has not enough arguments. /// Returns `Err` if this list has not enough arguments.
pub fn nth_value_checked(&self, idx: usize) -> Result<RuntimeValue, Trap> { pub fn nth_value_checked(&self, idx: usize) -> Result<RuntimeValue, Trap> {
if self.0.len() <= idx { if self.0.len() <= idx {
return Err(Trap::new(TrapKind::UnexpectedSignature)); return Err(TrapKind::UnexpectedSignature.into());
} }
Ok(self.0[idx]) Ok(self.0[idx])
} }
@ -207,7 +207,7 @@ impl Externals for NopExternals {
_index: usize, _index: usize,
_args: RuntimeArgs, _args: RuntimeArgs,
) -> Result<Option<RuntimeValue>, Trap> { ) -> Result<Option<RuntimeValue>, Trap> {
Err(Trap::new(TrapKind::Unreachable)) Err(TrapKind::Unreachable.into())
} }
} }

View File

@ -92,7 +92,7 @@ impl Externals for TestHost {
ERR_FUNC_INDEX => { ERR_FUNC_INDEX => {
let error_code: u32 = args.nth(0); let error_code: u32 = args.nth(0);
let error = HostErrorWithCode { error_code }; let error = HostErrorWithCode { error_code };
Err(Trap::new(TrapKind::Host(Box::new(error)))) Err(TrapKind::Host(Box::new(error)).into())
} }
INC_MEM_FUNC_INDEX => { INC_MEM_FUNC_INDEX => {
let ptr: u32 = args.nth(0); let ptr: u32 = args.nth(0);
@ -131,7 +131,7 @@ impl Externals for TestHost {
.expect("expected to be Some"); .expect("expected to be Some");
if val.value_type() != result.value_type() { 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)) Ok(Some(result))
} }