From 1c342cc44b9317907aa4ccced66a7ff81dd29ed0 Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Thu, 26 Oct 2023 16:13:40 -0500 Subject: [PATCH] chore: clippy --- crates/anvil/src/eth/api.rs | 4 ++-- crates/cast/bin/main.rs | 2 +- crates/cheatcodes/src/impls/test/expect.rs | 4 ++-- crates/evm/src/executor/inspector/cheatcodes/expect.rs | 4 ++-- crates/forge/bin/cmd/script/cmd.rs | 2 +- crates/forge/bin/cmd/test/mod.rs | 2 +- crates/zkcast/bin/main.rs | 2 +- crates/zkforge/bin/cmd/script/cmd.rs | 2 +- crates/zkforge/bin/cmd/test/mod.rs | 2 +- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/crates/anvil/src/eth/api.rs b/crates/anvil/src/eth/api.rs index d7f875c4f..313ecfb4e 100644 --- a/crates/anvil/src/eth/api.rs +++ b/crates/anvil/src/eth/api.rs @@ -805,7 +805,7 @@ impl EthApi { node_info!("eth_signTransaction"); let from = request.from.map(Ok).unwrap_or_else(|| { - self.accounts()?.get(0).cloned().ok_or(BlockchainError::NoSignerAvailable) + self.accounts()?.first().cloned().ok_or(BlockchainError::NoSignerAvailable) })?; let (nonce, _) = self.request_nonce(&request, from).await?; @@ -824,7 +824,7 @@ impl EthApi { node_info!("eth_sendTransaction"); let from = request.from.map(Ok).unwrap_or_else(|| { - self.accounts()?.get(0).cloned().ok_or(BlockchainError::NoSignerAvailable) + self.accounts()?.first().cloned().ok_or(BlockchainError::NoSignerAvailable) })?; let (nonce, on_chain_nonce) = self.request_nonce(&request, from).await?; diff --git a/crates/cast/bin/main.rs b/crates/cast/bin/main.rs index 8949f5c87..b2ac3a667 100644 --- a/crates/cast/bin/main.rs +++ b/crates/cast/bin/main.rs @@ -358,7 +358,7 @@ async fn main() -> Result<()> { let sig = match sigs.len() { 0 => eyre::bail!("No signatures found"), - 1 => sigs.get(0).unwrap(), + 1 => sigs.first().unwrap(), _ => { let i: usize = prompt!("Select a function signature by number: ")?; sigs.get(i - 1).ok_or_else(|| eyre::eyre!("Invalid signature index"))? diff --git a/crates/cheatcodes/src/impls/test/expect.rs b/crates/cheatcodes/src/impls/test/expect.rs index 1551440f5..218fdd1b9 100644 --- a/crates/cheatcodes/src/impls/test/expect.rs +++ b/crates/cheatcodes/src/impls/test/expect.rs @@ -395,8 +395,8 @@ pub(crate) fn handle_expect_emit( return }; - let expected_topic_0 = expected.topics().get(0); - let log_topic_0 = topics.get(0); + let expected_topic_0 = expected.topics().first(); + let log_topic_0 = topics.first(); if expected_topic_0 .zip(log_topic_0) diff --git a/crates/evm/src/executor/inspector/cheatcodes/expect.rs b/crates/evm/src/executor/inspector/cheatcodes/expect.rs index 51ff72f91..a14344a92 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/expect.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/expect.rs @@ -153,8 +153,8 @@ pub fn handle_expect_emit(state: &mut Cheatcodes, log: RawLog, address: &Address match event_to_fill_or_check.log { Some(ref expected) => { - let expected_topic_0 = expected.topics().get(0); - let log_topic_0 = log.topics().get(0); + let expected_topic_0 = expected.topics().first(); + let log_topic_0 = log.topics().first(); // same topic0 and equal number of topics should be verified further, others are a no // match diff --git a/crates/forge/bin/cmd/script/cmd.rs b/crates/forge/bin/cmd/script/cmd.rs index 77cd60e78..556422f4f 100644 --- a/crates/forge/bin/cmd/script/cmd.rs +++ b/crates/forge/bin/cmd/script/cmd.rs @@ -352,7 +352,7 @@ impl ScriptArgs { } if let Some(wallets) = self.wallets.private_keys()? { if wallets.len() == 1 { - script_config.evm_opts.sender = wallets.get(0).unwrap().address().to_alloy() + script_config.evm_opts.sender = wallets.first().unwrap().address().to_alloy() } } Ok(()) diff --git a/crates/forge/bin/cmd/test/mod.rs b/crates/forge/bin/cmd/test/mod.rs index ef67fb2e7..182b0d161 100644 --- a/crates/forge/bin/cmd/test/mod.rs +++ b/crates/forge/bin/cmd/test/mod.rs @@ -217,7 +217,7 @@ impl TestArgs { } let test_funcs = runner.get_matching_test_functions(&filter); // if we debug a fuzz test, we should not collect data on the first run - if !test_funcs.get(0).expect("matching function exists").inputs.is_empty() { + if !test_funcs.first().expect("matching function exists").inputs.is_empty() { runner_builder = runner_builder.set_debug(false); runner = runner_builder.clone().build( project_root, diff --git a/crates/zkcast/bin/main.rs b/crates/zkcast/bin/main.rs index f30773c3e..53f513600 100644 --- a/crates/zkcast/bin/main.rs +++ b/crates/zkcast/bin/main.rs @@ -360,7 +360,7 @@ async fn main() -> Result<()> { let sig = match sigs.len() { 0 => eyre::bail!("No signatures found"), - 1 => sigs.get(0).unwrap(), + 1 => sigs.first().unwrap(), _ => { let i: usize = prompt!("Select a function signature by number: ")?; sigs.get(i - 1).ok_or_else(|| eyre::eyre!("Invalid signature index"))? diff --git a/crates/zkforge/bin/cmd/script/cmd.rs b/crates/zkforge/bin/cmd/script/cmd.rs index 77cd60e78..556422f4f 100644 --- a/crates/zkforge/bin/cmd/script/cmd.rs +++ b/crates/zkforge/bin/cmd/script/cmd.rs @@ -352,7 +352,7 @@ impl ScriptArgs { } if let Some(wallets) = self.wallets.private_keys()? { if wallets.len() == 1 { - script_config.evm_opts.sender = wallets.get(0).unwrap().address().to_alloy() + script_config.evm_opts.sender = wallets.first().unwrap().address().to_alloy() } } Ok(()) diff --git a/crates/zkforge/bin/cmd/test/mod.rs b/crates/zkforge/bin/cmd/test/mod.rs index bc0c3be72..04dc6b6fa 100644 --- a/crates/zkforge/bin/cmd/test/mod.rs +++ b/crates/zkforge/bin/cmd/test/mod.rs @@ -225,7 +225,7 @@ impl TestArgs { } let test_funcs = runner.get_matching_test_functions(&filter); // if we debug a fuzz test, we should not collect data on the first run - if !test_funcs.get(0).expect("matching function exists").inputs.is_empty() { + if !test_funcs.first().expect("matching function exists").inputs.is_empty() { runner_builder = runner_builder.set_debug(false); runner = runner_builder.clone().build( project_root,