From 945044457edb69a29a578c5c23ac2bd3b6617e74 Mon Sep 17 00:00:00 2001 From: chungquantin <56880684+chungquantin@users.noreply.github.com> Date: Thu, 10 Oct 2024 00:05:53 +0700 Subject: [PATCH] refactor: unwrap_or_else --- crates/pop-drink/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/pop-drink/src/lib.rs b/crates/pop-drink/src/lib.rs index d67639a..d6a9ff0 100644 --- a/crates/pop-drink/src/lib.rs +++ b/crates/pop-drink/src/lib.rs @@ -112,14 +112,14 @@ where match session.call::(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::() - .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"), }