From c34a71556525f78e696940228987908c5d478a4c Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 24 May 2022 17:48:05 +0200 Subject: [PATCH] rust: Replace unwrap with ok_or where possible --- bindings/rust/src/lib.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/bindings/rust/src/lib.rs b/bindings/rust/src/lib.rs index 5206bb43c..b8a41b759 100644 --- a/bindings/rust/src/lib.rs +++ b/bindings/rust/src/lib.rs @@ -513,11 +513,9 @@ impl Instance { name: &str, args: &[TypedValue], ) -> Result { - let func_idx = self.find_exported_function_index(name); - if func_idx.is_none() { - return Err(Error::FunctionNotFound); - } - let func_idx = func_idx.unwrap(); + let func_idx = self + .find_exported_function_index(name) + .ok_or(Error::FunctionNotFound)?; let func_type = unsafe { self.get_function_type(func_idx) }; if func_type.inputs_size != args.len() {