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

feat(clippy): add iter_without_into_iter #9195

Merged
merged 5 commits into from
Jul 1, 2024
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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ zero_sized_map_values = "warn"
single_char_pattern = "warn"
needless_continue = "warn"
enum_glob_use = "warn"
iter_without_into_iter = "warn"

# These are nursery lints which have findings. Allow them for now. Some are not
# quite mature enough for use in our codebase and some we don't really want.
Expand Down
17 changes: 17 additions & 0 deletions crates/primitives-traits/src/withdrawal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,23 @@ impl Withdrawals {
}
}

impl<'a> IntoIterator for &'a Withdrawals {
type Item = &'a Withdrawal;
type IntoIter = core::slice::Iter<'a, Withdrawal>;
fn into_iter(self) -> Self::IntoIter {
self.iter()
}
}

impl<'a> IntoIterator for &'a mut Withdrawals {
type Item = &'a mut Withdrawal;
type IntoIter = core::slice::IterMut<'a, Withdrawal>;

fn into_iter(self) -> Self::IntoIter {
self.iter_mut()
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
8 changes: 8 additions & 0 deletions crates/trie/trie/src/prefix_set/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,14 @@ impl PrefixSet {
}
}

impl<'a> IntoIterator for &'a PrefixSet {
type IntoIter = std::slice::Iter<'a, reth_trie_common::Nibbles>;
type Item = &'a reth_trie_common::Nibbles;
fn into_iter(self) -> Self::IntoIter {
self.iter()
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
Loading