From b0c265bb27728b760ba650383d72e6966c318508 Mon Sep 17 00:00:00 2001 From: Jeff Grunewald Date: Mon, 10 Apr 2023 15:58:22 -0400 Subject: [PATCH] convert "or's" to "or_else's" Co-authored-by: Matthew Plant --- iot_config/src/admin.rs | 2 +- iot_config/src/gateway_info.rs | 2 +- iot_config/src/gateway_service.rs | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/iot_config/src/admin.rs b/iot_config/src/admin.rs index 71addbdb4..b1554fcb5 100644 --- a/iot_config/src/admin.rs +++ b/iot_config/src/admin.rs @@ -99,7 +99,7 @@ impl KeyType { pub fn from_i32(v: i32) -> anyhow::Result { ProtoKeyType::from_i32(v) .map(|kt| kt.into()) - .ok_or(anyhow!("unsupported key type {}", v)) + .ok_or_else(|| anyhow!("unsupported key type {}", v)) } } diff --git a/iot_config/src/gateway_info.rs b/iot_config/src/gateway_info.rs index cd716fa8b..d4e971d96 100644 --- a/iot_config/src/gateway_info.rs +++ b/iot_config/src/gateway_info.rs @@ -62,7 +62,7 @@ fn h3index_to_region( ) -> anyhow::Result { hextree::Cell::from_raw(location) .map(|cell| region_map.get_region(cell))? - .ok_or(anyhow!("invalid region")) + .ok_or_else(|| anyhow!("invalid region")) } #[async_trait::async_trait] diff --git a/iot_config/src/gateway_service.rs b/iot_config/src/gateway_service.rs index c0198ab89..e424537a9 100644 --- a/iot_config/src/gateway_service.rs +++ b/iot_config/src/gateway_service.rs @@ -206,9 +206,7 @@ impl iot_config::Gateway for GatewayService { let metadata_info = gateway_info::db::get_info(&self.metadata_pool, address) .await .map_err(|_| Status::internal("error fetching gateway info"))? - .ok_or(Status::not_found(format!( - "gateway not found: pubkey = {address:}" - )))?; + .ok_or_else(|| Status::not_found(format!("gateway not found: pubkey = {address:}")))?; let gateway_info = GatewayInfo::chain_metadata_to_info(metadata_info, &self.region_map); let mut resp = GatewayInfoResV1 {