Skip to content

Commit be34f5b

Browse files
authored
chore(clippy): use next_back instead of last for DoubleEndedIterator (#9666)
* chore(clippy): use next_back instead of last for DoubleEndedIterator Signed-off-by: jsvisa <[email protected]> * more cases Signed-off-by: jsvisa <[email protected]> * last -> next_back Signed-off-by: jsvisa <[email protected]> * len ==0 => is_empty Signed-off-by: jsvisa <[email protected]> --------- Signed-off-by: jsvisa <[email protected]>
1 parent 761d9e1 commit be34f5b

File tree

6 files changed

+7
-7
lines changed

6 files changed

+7
-7
lines changed

crates/anvil/src/eth/otterscan/api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl EthApi {
122122
pub async fn ots_has_code(&self, address: Address, block_number: BlockNumber) -> Result<bool> {
123123
node_info!("ots_hasCode");
124124
let block_id = Some(BlockId::Number(block_number));
125-
Ok(self.get_code(address, block_id).await?.len() > 0)
125+
Ok(!self.get_code(address, block_id).await?.is_empty())
126126
}
127127

128128
/// Trace a transaction and generate a trace call tree.

crates/cli/src/opts/dependency.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl FromStr for Dependency {
120120
let url = url.to_string();
121121
let name = url
122122
.split('/')
123-
.last()
123+
.next_back()
124124
.ok_or_else(|| eyre::eyre!("no dependency name found"))?
125125
.to_string();
126126

crates/config/src/invariant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,6 @@ impl InvariantConfig {
7575
self.failure_persist_dir
7676
.unwrap()
7777
.join("failures")
78-
.join(contract_name.split(':').last().unwrap())
78+
.join(contract_name.split(':').next_back().unwrap())
7979
}
8080
}

crates/doc/src/builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ impl DocBuilder {
389389
}
390390

391391
if let Some(path) = base_path {
392-
let title = path.iter().last().unwrap().to_string_lossy();
392+
let title = path.iter().next_back().unwrap().to_string_lossy();
393393
if depth == 1 {
394394
summary.write_title(&title)?;
395395
} else {
@@ -444,7 +444,7 @@ impl DocBuilder {
444444
readme.write_link_list_item(ident, &readme_path.display().to_string(), 0)?;
445445
}
446446
} else {
447-
let name = path.iter().last().unwrap().to_string_lossy();
447+
let name = path.iter().next_back().unwrap().to_string_lossy();
448448
let readme_path = Path::new("/").join(&path).display().to_string();
449449
readme.write_link_list_item(&name, &readme_path, 0)?;
450450
self.write_summary_section(summary, &files, Some(&path), depth + 1)?;

crates/forge/bin/cmd/test/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ impl TestArgs {
358358
let mut fst = folded_stack_trace::build(arena);
359359

360360
let label = if self.flamegraph { "flamegraph" } else { "flamechart" };
361-
let contract = suite_name.split(':').last().unwrap();
361+
let contract = suite_name.split(':').next_back().unwrap();
362362
let test_name = test_name.trim_end_matches("()");
363363
let file_name = format!("cache/{label}_{contract}_{test_name}.svg");
364364
let file = std::fs::File::create(&file_name).wrap_err("failed to create file")?;

crates/verify/src/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ pub fn check_args_len(
309309
args: &Bytes,
310310
) -> Result<(), eyre::ErrReport> {
311311
if let Some(constructor) = artifact.abi.as_ref().and_then(|abi| abi.constructor()) {
312-
if !constructor.inputs.is_empty() && args.len() == 0 {
312+
if !constructor.inputs.is_empty() && args.is_empty() {
313313
eyre::bail!(
314314
"Contract expects {} constructor argument(s), but none were provided",
315315
constructor.inputs.len()

0 commit comments

Comments
 (0)