Replace if statement with call to Option::map
This CL replaces an if-statement with a call to the Option::map
function. Having manual implementations of Option::map became a warning
with the 1.52.1 compiler update, and this was promoted to an error by
the build system.
Test: TH
Change-Id: I13e4adfbc84fbe855fd7d573e43e65bf602e0a5b
diff --git a/keystore2/src/super_key.rs b/keystore2/src/super_key.rs
index e02d9bc..bae18b0 100644
--- a/keystore2/src/super_key.rs
+++ b/keystore2/src/super_key.rs
@@ -126,10 +126,8 @@
fn from_metadata(metadata: &BlobMetaData) -> Option<Self> {
if let Some(EncryptedBy::KeyId(key_id)) = metadata.encrypted_by() {
Some(SuperKeyIdentifier::DatabaseId(*key_id))
- } else if let Some(boot_level) = metadata.max_boot_level() {
- Some(SuperKeyIdentifier::BootLevel(*boot_level))
} else {
- None
+ metadata.max_boot_level().map(|boot_level| SuperKeyIdentifier::BootLevel(*boot_level))
}
}