From 4821368c5256e3b90b44774349f50fe82d530ea0 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Mon, 29 Jan 2018 16:52:11 +0300 Subject: [PATCH] get_local can't fail. --- src/runner.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/runner.rs b/src/runner.rs index 30af5bd..d1fb3af 100644 --- a/src/runner.rs +++ b/src/runner.rs @@ -486,9 +486,9 @@ impl<'a, E: Externals> Interpreter<'a, E> { } fn run_get_local(&mut self, context: &mut FunctionContext, index: u32) -> Result { - context.get_local(index as usize) - .map(|value| context.value_stack_mut().push(value)) - .map(|_| InstructionOutcome::RunNextInstruction) + let value = context.get_local(index as usize); + context.value_stack_mut().push(value)?; + Ok(InstructionOutcome::RunNextInstruction) } fn run_set_local(&mut self, context: &mut FunctionContext, index: u32) -> Result { @@ -1071,10 +1071,10 @@ impl FunctionContext { Ok(InstructionOutcome::RunNextInstruction) } - pub fn get_local(&mut self, index: usize) -> Result { - Ok(self.locals.get(index) + pub fn get_local(&mut self, index: usize) -> RuntimeValue { + self.locals.get(index) .cloned() - .expect("Due to validation local should exists")) + .expect("Due to validation local should exists") } pub fn value_stack(&self) -> &StackWithLimit {