Skip to content

Commit

Permalink
rust: Replace unwrap with ok_or where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed May 24, 2022
1 parent 8482896 commit c34a715
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions bindings/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,11 +513,9 @@ impl Instance {
name: &str,
args: &[TypedValue],
) -> Result<TypedExecutionResult, Error> {
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() {
Expand Down

0 comments on commit c34a715

Please sign in to comment.