Detailed changes
@@ -820,6 +820,11 @@ single_range_in_vec_init = "allow"
style = { level = "allow", priority = -1 }
# Temporary list of style lints that we've fixed so far.
+iter_cloned_collect = "warn"
+iter_next_slice = "warn"
+iter_nth = "warn"
+iter_nth_zero = "warn"
+iter_skip_next = "warn"
module_inception = { level = "deny" }
question_mark = { level = "deny" }
redundant_closure = { level = "deny" }
@@ -503,8 +503,7 @@ fn update_editor_selection(
&[last_kept_hunk_end..editor::Anchor::max()],
buffer_snapshot,
)
- .skip(1)
- .next()
+ .nth(1)
})
.or_else(|| {
let first_kept_hunk = diff_hunks.first()?;
@@ -690,11 +690,7 @@ impl MessageEditor {
.as_ref()
.map(|model| {
self.incompatible_tools_state.update(cx, |state, cx| {
- state
- .incompatible_tools(&model.model, cx)
- .iter()
- .cloned()
- .collect::<Vec<_>>()
+ state.incompatible_tools(&model.model, cx).to_vec()
})
})
.unwrap_or_default();
@@ -747,11 +747,7 @@ impl TextThreadEditor {
self.context.read(cx).invoked_slash_command(&command_id)
{
if let InvokedSlashCommandStatus::Finished = invoked_slash_command.status {
- let run_commands_in_ranges = invoked_slash_command
- .run_commands_in_ranges
- .iter()
- .cloned()
- .collect::<Vec<_>>();
+ let run_commands_in_ranges = invoked_slash_command.run_commands_in_ranges.clone();
for range in run_commands_in_ranges {
let commands = self.context.update(cx, |context, cx| {
context.reparse(cx);
@@ -272,7 +272,7 @@ impl VariableList {
let mut entries = vec![];
let scopes: Vec<_> = self.session.update(cx, |session, cx| {
- session.scopes(stack_frame_id, cx).iter().cloned().collect()
+ session.scopes(stack_frame_id, cx).to_vec()
});
let mut contains_local_scope = false;
@@ -20932,7 +20932,7 @@ impl Editor {
let existing_pending = self
.text_highlights::<PendingInput>(cx)
- .map(|(_, ranges)| ranges.iter().cloned().collect::<Vec<_>>());
+ .map(|(_, ranges)| ranges.to_vec());
if existing_pending.is_none() && pending.is_empty() {
return;
}
@@ -2756,7 +2756,7 @@ impl GitPanel {
for pending in self.pending.iter() {
if pending.target_status == TargetStatus::Staged {
pending_staged_count += pending.entries.len();
- last_pending_staged = pending.entries.iter().next().cloned();
+ last_pending_staged = pending.entries.first().cloned();
}
if let Some(single_staged) = &single_staged_entry {
if pending
@@ -5261,7 +5261,7 @@ mod tests {
project
.read(cx)
.worktrees(cx)
- .nth(0)
+ .next()
.unwrap()
.read(cx)
.as_local()
@@ -5386,7 +5386,7 @@ mod tests {
project
.read(cx)
.worktrees(cx)
- .nth(0)
+ .next()
.unwrap()
.read(cx)
.as_local()
@@ -5437,7 +5437,7 @@ mod tests {
project
.read(cx)
.worktrees(cx)
- .nth(0)
+ .next()
.unwrap()
.read(cx)
.as_local()
@@ -5486,7 +5486,7 @@ mod tests {
project
.read(cx)
.worktrees(cx)
- .nth(0)
+ .next()
.unwrap()
.read(cx)
.as_local()
@@ -280,7 +280,7 @@ impl ProjectDiff {
fn button_states(&self, cx: &App) -> ButtonStates {
let editor = self.editor.read(cx);
let snapshot = self.multibuffer.read(cx).snapshot(cx);
- let prev_next = snapshot.diff_hunks().skip(1).next().is_some();
+ let prev_next = snapshot.diff_hunks().nth(1).is_some();
let mut selection = true;
let mut ranges = editor
@@ -86,7 +86,7 @@ pub fn serialize_operation(operation: &crate::Operation) -> proto::Operation {
proto::operation::UpdateCompletionTriggers {
replica_id: lamport_timestamp.replica_id as u32,
lamport_timestamp: lamport_timestamp.value,
- triggers: triggers.iter().cloned().collect(),
+ triggers: triggers.clone(),
language_server_id: server_id.to_proto(),
},
),
@@ -98,9 +98,7 @@ impl KeyContextView {
cx.notify();
});
let sub2 = cx.observe_pending_input(window, |this, window, cx| {
- this.pending_keystrokes = window
- .pending_input_keystrokes()
- .map(|k| k.iter().cloned().collect());
+ this.pending_keystrokes = window.pending_input_keystrokes().map(|k| k.to_vec());
if this.pending_keystrokes.is_some() {
this.last_keystrokes.take();
}
@@ -472,13 +472,7 @@ impl KeymapEditor {
fn current_keystroke_query(&self, cx: &App) -> Vec<Keystroke> {
match self.search_mode {
- SearchMode::KeyStroke { .. } => self
- .keystroke_editor
- .read(cx)
- .keystrokes()
- .iter()
- .cloned()
- .collect(),
+ SearchMode::KeyStroke { .. } => self.keystroke_editor.read(cx).keystrokes().to_vec(),
SearchMode::Normal => Default::default(),
}
}
@@ -601,7 +601,7 @@ fn pick_default_screen(cx: &App) -> Task<anyhow::Result<Option<Rc<dyn ScreenCapt
.metadata()
.is_ok_and(|meta| meta.is_main.unwrap_or_default())
})
- .or_else(|| available_sources.iter().next())
+ .or_else(|| available_sources.first())
.cloned())
})
}
@@ -221,7 +221,7 @@ pub(crate) fn register(editor: &mut Editor, cx: &mut Context<Vim>) {
return;
};
- let anchors = last_change.iter().cloned().collect::<Vec<_>>();
+ let anchors = last_change.to_vec();
let mut last_row = None;
let ranges: Vec<_> = anchors
.iter()