Skip to content

Commit

Permalink
refactor: unwrap_or_else
Browse files Browse the repository at this point in the history
  • Loading branch information
chungquantin committed Oct 9, 2024
1 parent b17157f commit 9450444
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions crates/pop-drink/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,14 @@ where
match session.call::<String, ()>(func_name, &input, endowment) {
// If the call is reverted, decode the error into the specified error type.
Err(SessionError::CallReverted(error)) => {
Err(E::decode(&mut &error[2..]).unwrap_or_else(|_| panic!("Decoding failed")))
Err(E::decode(&mut &error[2..]).expect("Decoding failed"))
},
// If the call is successful, decode the last returned value.
Ok(_) => Ok(session
.record()
.last_call_return_decoded::<O>()
.unwrap_or_else(|_| panic!("Expected a return value"))
.unwrap_or_else(|_| panic!("Decoding failed"))),
.expect("Expected a return value")
.expect("Decoding failed")),
// Catch-all for unexpected results.
_ => panic!("Expected call to revert or return a value"),
}
Expand Down

0 comments on commit 9450444

Please sign in to comment.