pvattest: Use map_or and map_or_else

Replace 'match .. { Some(v) => y, None/_ => x }' statements with
'Option::map_or_else' and 'Option::map_or'. See
https://rust-lang.github.io/rust-clippy/master/index.html#option_if_let_else.

Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Marc Hartmayer
2024-12-03 15:43:50 +01:00
committed by Jan Höppner
parent b1ca60f5ba
commit 6c75a06b12
2 changed files with 12 additions and 23 deletions
+3 -4
View File
@@ -56,10 +56,9 @@ impl Display for Response {
if self.valid { "" } else { "not " }
)?;
match &self.reason {
Some(r) => write!(f, "\n Reason: {r}\n ReferenceId: {}", self.reference_id),
None => Ok(()),
}
self.reason.as_ref().map_or(Ok(()), |r| {
write!(f, "\n Reason: {r}\n ReferenceId: {}", self.reference_id)
})
}
}