From 676f03923049ab95bc3ae9c106343f4cf200ff3e Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 11 Oct 2022 19:49:05 +0200 Subject: [PATCH] chore(clippy): make clippy happy (#1778) --- ethers-core/src/abi/human_readable/mod.rs | 3 ++- ethers-etherscan/src/lib.rs | 2 +- ethers-etherscan/src/utils.rs | 2 +- ethers-middleware/src/gas_escalator/linear.rs | 2 +- examples/abigen.rs | 4 ++-- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ethers-core/src/abi/human_readable/mod.rs b/ethers-core/src/abi/human_readable/mod.rs index 4b5125ff..192fa42c 100644 --- a/ethers-core/src/abi/human_readable/mod.rs +++ b/ethers-core/src/abi/human_readable/mod.rs @@ -464,7 +464,8 @@ impl AbiParser { fn parse_param(&self, param: &str) -> Result<(Param, Option)> { let mut iter = param.trim().rsplitn(3, is_whitespace); - let mut name = iter.next().ok_or(ParseError::ParseError(super::Error::InvalidData))?; + let mut name = + iter.next().ok_or_else(|| ParseError::ParseError(super::Error::InvalidData))?; let type_str; if let Some(ty) = iter.last() { diff --git a/ethers-etherscan/src/lib.rs b/ethers-etherscan/src/lib.rs index 25c940a4..4df3ebf2 100644 --- a/ethers-etherscan/src/lib.rs +++ b/ethers-etherscan/src/lib.rs @@ -270,7 +270,7 @@ impl ClientBuilder { let (etherscan_api_url, etherscan_url) = chain .etherscan_urls() .map(|(api, base)| urls(api, base)) - .ok_or(EtherscanError::ChainNotSupported(chain))?; + .ok_or_else(|| EtherscanError::ChainNotSupported(chain))?; self.with_api_url(etherscan_api_url?)?.with_url(etherscan_url?) } diff --git a/ethers-etherscan/src/utils.rs b/ethers-etherscan/src/utils.rs index f3588bab..b76745eb 100644 --- a/ethers-etherscan/src/utils.rs +++ b/ethers-etherscan/src/utils.rs @@ -16,7 +16,7 @@ pub async fn lookup_compiler_version(version: &Version) -> Result { .lines() .find(|l| !l.contains("nightly") && l.contains(&version)) .map(|l| l.trim_start_matches("soljson-v").trim_end_matches(".js")) - .ok_or(EtherscanError::MissingSolcVersion(version))?; + .ok_or_else(|| EtherscanError::MissingSolcVersion(version))?; Ok(v.parse().expect("failed to parse semver")) } diff --git a/ethers-middleware/src/gas_escalator/linear.rs b/ethers-middleware/src/gas_escalator/linear.rs index 308b8ba9..9eefca99 100644 --- a/ethers-middleware/src/gas_escalator/linear.rs +++ b/ethers-middleware/src/gas_escalator/linear.rs @@ -32,7 +32,7 @@ impl LinearGasPrice { impl GasEscalator for LinearGasPrice { fn get_gas_price(&self, initial_price: U256, time_elapsed: u64) -> U256 { - let mut result = initial_price + self.increase_by * (time_elapsed / self.every_secs) as u64; + let mut result = initial_price + self.increase_by * (time_elapsed / self.every_secs); dbg!(time_elapsed, self.every_secs); if let Some(max_price) = self.max_price { result = std::cmp::min(result, max_price); diff --git a/examples/abigen.rs b/examples/abigen.rs index 5880d115..33dd69d3 100644 --- a/examples/abigen.rs +++ b/examples/abigen.rs @@ -4,8 +4,8 @@ fn main() -> eyre::Result<()> { let mut args = std::env::args(); args.next().unwrap(); // skip program name - let contract_name = args.next().unwrap_or("SimpleStorage".to_owned()); - let contract: String = args.next().unwrap_or("examples/contract.sol".to_owned()); + let contract_name = args.next().unwrap_or_else(|| "SimpleStorage".to_owned()); + let contract: String = args.next().unwrap_or_else(|| "examples/contract.sol".to_owned()); println!("Generating bindings for {}\n", contract);