Simplify iteration idioms (#13834)

Remove unnecessary uses of `.as_ref()`, `.iter()`, `&**` and similar, mostly in situations when iterating over variables. Many of these changes are only possible following #13826, when we bumped our MSRV to 1.80: several useful implementations on `&Box<[T]>` were only stabilised in Rust 1.80. Some of these changes we could have done earlier, however.
This commit is contained in:
Alex Waygood 2024-10-20 22:25:27 +01:00 committed by GitHub
parent 7fd8e30eed
commit 72adb09bf3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
36 changed files with 72 additions and 73 deletions

View file

@ -803,7 +803,7 @@ impl LintConfiguration {
.select
.iter()
.flatten()
.chain(selection.extend_select.iter())
.chain(&selection.extend_select)
.filter(|s| s.specificity() == spec)
{
for rule in selector.rules(&preview) {
@ -830,7 +830,7 @@ impl LintConfiguration {
.fixable
.iter()
.flatten()
.chain(selection.extend_fixable.iter())
.chain(&selection.extend_fixable)
.filter(|s| s.specificity() == spec)
{
for rule in selector.all_rules() {

View file

@ -219,7 +219,7 @@ impl<'a> Resolver<'a> {
/// Return an iterator over the resolved [`Settings`] in this [`Resolver`].
pub fn settings(&self) -> impl Iterator<Item = &Settings> {
std::iter::once(&self.pyproject_config.settings).chain(self.settings.iter())
std::iter::once(&self.pyproject_config.settings).chain(&self.settings)
}
}