Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit 3f3a7ef

Browse files
authored
unify &Option<T> to Option<&T> (paradigmxyz#11755)
1 parent d4be773 commit 3f3a7ef

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

crates/cli/commands/src/db/get.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,8 @@ pub(crate) fn table_key<T: Table>(key: &str) -> Result<T::Key, eyre::Error> {
132132
}
133133

134134
/// Get an instance of subkey for given dupsort table
135-
fn table_subkey<T: DupSort>(subkey: &Option<String>) -> Result<T::SubKey, eyre::Error> {
136-
serde_json::from_str::<T::SubKey>(&subkey.clone().unwrap_or_default())
137-
.map_err(|e| eyre::eyre!(e))
135+
fn table_subkey<T: DupSort>(subkey: Option<&str>) -> Result<T::SubKey, eyre::Error> {
136+
serde_json::from_str::<T::SubKey>(subkey.unwrap_or_default()).map_err(|e| eyre::eyre!(e))
138137
}
139138

140139
struct GetValueViewer<'a, N: NodeTypesWithDB> {
@@ -175,7 +174,7 @@ impl<N: ProviderNodeTypes> TableViewer<()> for GetValueViewer<'_, N> {
175174
let key = table_key::<T>(&self.key)?;
176175

177176
// process dupsort table
178-
let subkey = table_subkey::<T>(&self.subkey)?;
177+
let subkey = table_subkey::<T>(self.subkey.as_deref())?;
179178

180179
match self.tool.get_dup::<T>(key, subkey)? {
181180
Some(content) => {

crates/rpc/rpc-builder/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -676,8 +676,8 @@ impl RpcModuleConfigBuilder {
676676
}
677677

678678
/// Get a reference to the eth namespace config, if any
679-
pub const fn get_eth(&self) -> &Option<EthConfig> {
680-
&self.eth
679+
pub const fn get_eth(&self) -> Option<&EthConfig> {
680+
self.eth.as_ref()
681681
}
682682

683683
/// Get a mutable reference to the eth namespace config, if any

0 commit comments

Comments
 (0)