Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(clippy): use next_back instead of last for DoubleEndedIterator #9666

Merged
merged 4 commits into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/anvil/src/eth/otterscan/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl EthApi {
pub async fn ots_has_code(&self, address: Address, block_number: BlockNumber) -> Result<bool> {
node_info!("ots_hasCode");
let block_id = Some(BlockId::Number(block_number));
Ok(self.get_code(address, block_id).await?.len() > 0)
Ok(!self.get_code(address, block_id).await?.is_empty())
}

/// Trace a transaction and generate a trace call tree.
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/opts/dependency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl FromStr for Dependency {
let url = url.to_string();
let name = url
.split('/')
.last()
.next_back()
.ok_or_else(|| eyre::eyre!("no dependency name found"))?
.to_string();

Expand Down
2 changes: 1 addition & 1 deletion crates/config/src/invariant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ impl InvariantConfig {
self.failure_persist_dir
.unwrap()
.join("failures")
.join(contract_name.split(':').last().unwrap())
.join(contract_name.split(':').next_back().unwrap())
}
}
4 changes: 2 additions & 2 deletions crates/doc/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ impl DocBuilder {
}

if let Some(path) = base_path {
let title = path.iter().last().unwrap().to_string_lossy();
let title = path.iter().next_back().unwrap().to_string_lossy();
if depth == 1 {
summary.write_title(&title)?;
} else {
Expand Down Expand Up @@ -444,7 +444,7 @@ impl DocBuilder {
readme.write_link_list_item(ident, &readme_path.display().to_string(), 0)?;
}
} else {
let name = path.iter().last().unwrap().to_string_lossy();
let name = path.iter().next_back().unwrap().to_string_lossy();
let readme_path = Path::new("/").join(&path).display().to_string();
readme.write_link_list_item(&name, &readme_path, 0)?;
self.write_summary_section(summary, &files, Some(&path), depth + 1)?;
Expand Down
2 changes: 1 addition & 1 deletion crates/forge/bin/cmd/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ impl TestArgs {
let mut fst = folded_stack_trace::build(arena);

let label = if self.flamegraph { "flamegraph" } else { "flamechart" };
let contract = suite_name.split(':').last().unwrap();
let contract = suite_name.split(':').next_back().unwrap();
let test_name = test_name.trim_end_matches("()");
let file_name = format!("cache/{label}_{contract}_{test_name}.svg");
let file = std::fs::File::create(&file_name).wrap_err("failed to create file")?;
Expand Down
2 changes: 1 addition & 1 deletion crates/verify/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ pub fn check_args_len(
args: &Bytes,
) -> Result<(), eyre::ErrReport> {
if let Some(constructor) = artifact.abi.as_ref().and_then(|abi| abi.constructor()) {
if !constructor.inputs.is_empty() && args.len() == 0 {
if !constructor.inputs.is_empty() && args.is_empty() {
eyre::bail!(
"Contract expects {} constructor argument(s), but none were provided",
constructor.inputs.len()
Expand Down
Loading