From e6156e4672f0ad2bc965c32ed5c79b91c3bc3f54 Mon Sep 17 00:00:00 2001 From: nk_ysg Date: Wed, 26 Mar 2025 23:38:58 +0800 Subject: [PATCH] chore(storage_api): use map_or_else (#15302) --- crates/storage/storage-api/src/state.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/crates/storage/storage-api/src/state.rs b/crates/storage/storage-api/src/state.rs index 2e1e61f88b..ed961343fc 100644 --- a/crates/storage/storage-api/src/state.rs +++ b/crates/storage/storage-api/src/state.rs @@ -66,10 +66,8 @@ pub trait StateProvider: fn account_balance(&self, addr: &Address) -> ProviderResult> { // Get basic account information // Returns None if acc doesn't exist - match self.basic_account(addr)? { - Some(acc) => Ok(Some(acc.balance)), - None => Ok(None), - } + + self.basic_account(addr)?.map_or_else(|| Ok(None), |acc| Ok(Some(acc.balance))) } /// Get account nonce by its address. @@ -78,10 +76,7 @@ pub trait StateProvider: fn account_nonce(&self, addr: &Address) -> ProviderResult> { // Get basic account information // Returns None if acc doesn't exist - match self.basic_account(addr)? { - Some(acc) => Ok(Some(acc.nonce)), - None => Ok(None), - } + self.basic_account(addr)?.map_or_else(|| Ok(None), |acc| Ok(Some(acc.nonce))) } }