Enable and fix clippy::explicit_iter_loop
And sort the lints block while I'm at it
- Id
- bd97efb09380843d7ded1b4ea348c4099987e4cf
- Author
- Caio
- Commit time
- 2024-03-19T08:48:11+01:00
Modified urso/src/lib.rs
clippy::empty_enum,
clippy::enum_glob_use,
clippy::exit,
- clippy::expl_impl_clone_on_copy,
clippy::explicit_deref_methods,
clippy::explicit_into_iter_loop,
+ clippy::explicit_iter_loop,
+ clippy::expl_impl_clone_on_copy,
clippy::fallible_impl_from,
clippy::filter_map_next,
clippy::flat_map_option,
clippy::map_unwrap_or,
clippy::match_on_vec_items,
clippy::match_same_arms,
- clippy::match_wild_err_arm,
clippy::match_wildcard_for_single_variants,
+ clippy::match_wild_err_arm,
clippy::mem_forget,
clippy::mismatched_target_os,
clippy::missing_enforced_import_renames,
- clippy::mut_mut,
clippy::mutex_integer,
+ clippy::mut_mut,
clippy::needless_borrow,
clippy::needless_continue,
clippy::needless_for_each,
clippy::same_functions_in_if_condition,
clippy::semicolon_if_nothing_returned,
clippy::single_match_else,
- clippy::string_add_assign,
clippy::string_add,
+ clippy::string_add_assign,
clippy::string_lit_as_bytes,
clippy::string_to_string,
clippy::todo,
enqueue!(parent_id);
parent_id
} else {
- for &id in parent_ids.iter() {
+ for &id in &parent_ids {
enqueue!(id);
}
parent_ids[0]
Modified caca/src/repo/mod.rs
// now walk through the branches, using the tip as a
// guide to know wether there's any chance it contains
// recent commits
- for rev in self.snapshot.branches.iter() {
+ for rev in &self.snapshot.branches {
if rev.name == self.snapshot.head.name {
continue;
}
title: &self.title,
header_html: &self.header_html,
};
- for r in self.inner.iter() {
+ for r in &self.inner {
match r.snapshot.metadata.state {
State::Archived => listing.num_archived += 1,
State::Default => {}
return;
};
let mut topk = TopK::new(k);
- for repo in self.inner.iter() {
- for entry in repo.feed.iter() {
+ for repo in &self.inner {
+ for entry in &repo.feed {
if !topk.insert(GlobalFeedEntry {
repo: repo.name.clone(),
entry: entry.clone(),
Modified urso/src/blame/lines.rs
impl<T: PartialEq> From<Vec<Hunk<T>>> for Lines<T> {
fn from(inner: Vec<Hunk<T>>) -> Self {
assert!(!inner.is_empty());
- for h in inner.iter() {
+ for h in &inner {
assert_ne!(0, h.len);
}
Self(inner)
{
let mut tally = 0;
let mut i = 0;
- for hunk in state.iter() {
+ for hunk in state {
if tally == lineno {
return Pos::Left(i);
}
Modified urso/src/blame/mod.rs
let mut op = None;
let mut at = (chunk.before_pos.start as isize + offset) as u32;
assert!(chunk.before_pos.start as isize + offset >= 0);
- for line in chunk.lines.iter() {
+ for line in &chunk.lines {
match line {
Line::Addition(_) => {
offset += 1;
Modified urso/src/diff/mod.rs
impl std::fmt::Debug for UnifiedDiff {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- for c in self.chunks.iter() {
+ for c in &self.chunks {
c.format_patch(f)?;
}
Ok(())
pub fn as_patch(&self) -> std::result::Result<String, std::fmt::Error> {
let mut patch = String::new();
- for chunk in self.chunks.iter() {
+ for chunk in &self.chunks {
chunk.format_patch(&mut patch)?;
}
Ok(patch)
self.after_pos.start + 1,
self.after_pos.len(),
)?;
- for line in self.lines.iter() {
+ for line in &self.lines {
match line {
Line::Addition(s) => writeln!(f, "+{}", s)?,
Line::Removal(s) => writeln!(f, "-{}", s)?,
Modified urso/src/diff/sink.rs
self.before_hunk_len += range.end - range.start;
let range = range.start as usize..range.end as usize;
- for &line in self.input.before[range].iter() {
+ for &line in &self.input.before[range] {
self.lines.push(super::Line::Removal(String::from(
self.input.interner[line],
)));
fn register_additions(&mut self, range: Range<u32>) {
self.after_hunk_len += range.end - range.start;
- for &line in self.input.after[(range.start as usize)..(range.end as usize)].iter() {
+ for &line in &self.input.after[(range.start as usize)..(range.end as usize)] {
self.lines.push(super::Line::Addition(String::from(
self.input.interner[line],
)));
}
fn register_context(&mut self, range: Range<u32>) {
- for &line in self.input.before[(range.start as usize)..(range.end as usize)].iter() {
+ for &line in &self.input.before[(range.start as usize)..(range.end as usize)] {
self.lines.push(super::Line::Context(String::from(
self.input.interner[line],
)));