chore: clippy on redundant closure (#4058)

Add redundant closure clippy rules and let Codex fix it by minimising
FQP
This commit is contained in:
jif-oai
2025-09-22 20:30:16 +01:00
committed by GitHub
parent c75920a071
commit be366a31ab
43 changed files with 97 additions and 86 deletions

View File

@@ -421,7 +421,7 @@ impl ChatComposer {
// Capture any needed data from popup before clearing it.
let prompt_content = match sel {
CommandItem::UserPrompt(idx) => {
popup.prompt_content(idx).map(|s| s.to_string())
popup.prompt_content(idx).map(str::to_string)
}
_ => None,
};
@@ -550,7 +550,7 @@ impl ChatComposer {
let format_label = match Path::new(&sel_path)
.extension()
.and_then(|e| e.to_str())
.map(|s| s.to_ascii_lowercase())
.map(str::to_ascii_lowercase)
{
Some(ext) if ext == "png" => "PNG",
Some(ext) if ext == "jpg" || ext == "jpeg" => "JPEG",
@@ -617,7 +617,7 @@ impl ChatComposer {
text[safe_cursor..]
.chars()
.next()
.map(|c| c.is_whitespace())
.map(char::is_whitespace)
.unwrap_or(false)
} else {
false
@@ -645,7 +645,7 @@ impl ChatComposer {
let ws_len_right: usize = after_cursor
.chars()
.take_while(|c| c.is_whitespace())
.map(|c| c.len_utf8())
.map(char::len_utf8)
.sum();
let start_right = safe_cursor + ws_len_right;
let end_right_rel = text[start_right..]

View File

@@ -218,6 +218,7 @@ impl WidgetRef for CommandPopup {
#[cfg(test)]
mod tests {
use super::*;
use std::string::ToString;
#[test]
fn filter_includes_init_when_typing_prefix() {
@@ -287,7 +288,7 @@ mod tests {
let mut prompt_names: Vec<String> = items
.into_iter()
.filter_map(|it| match it {
CommandItem::UserPrompt(i) => popup.prompt_name(i).map(|s| s.to_string()),
CommandItem::UserPrompt(i) => popup.prompt_name(i).map(ToString::to_string),
_ => None,
})
.collect();

View File

@@ -103,7 +103,7 @@ impl BottomPane {
}
fn active_view(&self) -> Option<&dyn BottomPaneView> {
self.view_stack.last().map(|view| view.as_ref())
self.view_stack.last().map(std::convert::AsRef::as_ref)
}
fn push_view(&mut self, view: Box<dyn BottomPaneView>) {

View File

@@ -183,7 +183,7 @@ impl PasteBurst {
let start_byte = retro_start_index(before, retro_chars);
let grabbed = before[start_byte..].to_string();
let looks_pastey =
grabbed.chars().any(|c| c.is_whitespace()) || grabbed.chars().count() >= 16;
grabbed.chars().any(char::is_whitespace) || grabbed.chars().count() >= 16;
if looks_pastey {
// Note: caller is responsible for removing this slice from UI text.
self.begin_with_retro_grabbed(grabbed.clone(), now);