From 2b880b1e189f03cf3831ec522a867b1f59155e02 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Tue, 6 Feb 2018 13:57:15 +0300 Subject: [PATCH] Use .into() to convert TrapKind into Trap --- src/host.rs | 4 ++-- src/tests/host.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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)) }