chore: more pedantic clippy suggestions

This commit is contained in:
Cheong Lau 2025-10-26 16:20:51 +10:00
parent 5863671217
commit 5f729829d7
17 changed files with 1063 additions and 998 deletions

View file

@ -43,7 +43,7 @@ macro_rules! menu_button {
);
}
fn menu_button_optional(
const fn menu_button_optional(
label: String,
action: Action,
enabled: bool,
@ -61,7 +61,7 @@ pub fn context_menu<'a>(
modifiers: &Modifiers,
) -> Element<'a, tab::Message> {
let find_key = |action: &Action| -> String {
for (key_bind, key_action) in key_binds.iter() {
for (key_bind, key_action) in key_binds {
if action == key_action {
return key_bind.to_string();
}
@ -110,11 +110,11 @@ pub fn context_menu<'a>(
let mut selected_types: Vec<Mime> = vec![];
let mut selected_mount_point = 0;
if let Some(items) = tab.items_opt() {
for item in items.iter() {
for item in items {
if item.selected {
selected += 1;
if item.metadata.is_dir() {
selected_mount_point += item.is_mount_point as i32;
selected_mount_point += i32::from(item.is_mount_point);
selected_dir += 1;
}
match &item.location_opt {
@ -131,7 +131,7 @@ pub fn context_menu<'a>(
selected_types.push(item.mime.clone());
}
}
};
}
selected_types.sort_unstable();
selected_types.dedup();
selected_trash_only = selected_trash_only && selected == 1;
@ -168,7 +168,7 @@ pub fn context_menu<'a>(
#[cfg(feature = "desktop")]
{
for (i, action) in entry.desktop_actions.into_iter().enumerate() {
children.push(menu_item(action.name, Action::ExecEntryAction(i)).into())
children.push(menu_item(action.name, Action::ExecEntryAction(i)).into());
}
}
children.push(divider::horizontal::light().into());
@ -396,12 +396,12 @@ pub fn dialog_menu(
let mut selected_gallery = 0;
if let Some(items) = tab.items_opt() {
for item in items.iter() {
for item in items {
if item.selected && item.can_gallery() {
selected_gallery += 1;
}
}
};
}
MenuBar::new(vec![
menu::Tree::with_children(
@ -530,7 +530,7 @@ pub fn menu_bar<'a>(
modifiers: &Modifiers,
key_binds: &HashMap<KeyBind, Action>,
) -> Element<'a, Message> {
let sort_options = tab_opt.map(|tab| tab.sort_options());
let sort_options = tab_opt.map(Tab::sort_options);
let sort_item = |label, sort, dir| {
menu::Item::CheckBox(
label,
@ -547,7 +547,7 @@ pub fn menu_bar<'a>(
let mut selected = 0;
let mut selected_gallery = 0;
if let Some(items) = tab_opt.and_then(|tab| tab.items_opt()) {
for item in items.iter() {
for item in items {
if item.selected {
selected += 1;
if item.metadata.is_dir() {
@ -558,7 +558,7 @@ pub fn menu_bar<'a>(
}
}
}
};
}
let (delete_item, delete_item_action) = if in_trash || modifiers.shift() {
(fl!("delete-permanently"), Action::Delete)