trace-forwarder: Fix unnecessary_unwrap warnings in macro

Replace is_ok() check followed by unwrap()/unwrap_err() with if let
Ok()/Err() patterns in assert_result macro to fix clippy warnings in
Rust 1.93.

Assisted-by: IBM Bob
Signed-off-by: stevenhorsman <steven@uk.ibm.com>
This commit is contained in:
stevenhorsman
2026-04-20 09:00:55 +01:00
parent a700ed5bff
commit 3492e456c1

View File

@@ -27,12 +27,10 @@ pub const ERR_HVSOCK_SOC_PATH_EMPTY: &str = "Hybrid VSOCK socket path cannot be
#[macro_export]
macro_rules! assert_result {
($expected_result:expr, $actual_result:expr, $msg:expr) => {
if $expected_result.is_ok() {
let expected_level = $expected_result.as_ref().unwrap();
if let Ok(expected_level) = $expected_result.as_ref() {
let actual_level = $actual_result.unwrap();
assert!(*expected_level == actual_level, "{}", $msg);
} else {
let expected_error = $expected_result.as_ref().unwrap_err();
} else if let Err(expected_error) = $expected_result.as_ref() {
let expected_error_msg = format!("{:?}", expected_error);
if let Err(actual_error) = $actual_result {