chore: clippy

This commit is contained in:
Vukašin Vojinović 2026-04-28 14:45:01 +02:00 committed by Michael Murphy
parent 93e31d433a
commit e91a984da9
6 changed files with 45 additions and 52 deletions

View file

@ -1401,7 +1401,7 @@ impl App {
// Manually rescan any trash tabs after any operation is completed
commands.push(self.rescan_trash());
return Task::batch(commands);
Task::batch(commands)
}
fn handle_operation_errors(&mut self, errors: Vec<(u64, OperationError)>) -> Task<Message> {
@ -1446,7 +1446,7 @@ impl App {
}
// Manually rescan any trash tabs after any operation is completed
tasks.push(self.rescan_trash());
return Task::batch(tasks);
Task::batch(tasks)
}
fn remove_window(&mut self, id: &window::Id) {
@ -5661,7 +5661,7 @@ impl Application for App {
}
DialogPage::FailedOperations(ids) => {
let errors: Vec<String> = ids
.into_iter()
.iter()
.filter_map(|id| match self.failed_operations.get(id) {
Some((operation, _, err)) => Some(format!("{operation:#?}\n{err}")),
_ => None,

View file

@ -132,7 +132,7 @@ impl TryFrom<(Vec<u8>, String)> for ClipboardPaste {
match mime.as_str() {
"text/uri-list" => {
let text = str::from_utf8(&data)?;
let lines = text.lines();
let _lines = text.lines();
for line in text.lines() {
let url = Url::parse(line)?;

View file

@ -143,12 +143,11 @@ pub fn context_menu<'a>(
Some(Location::Trash) | Some(Location::Search(SearchLocation::Trash, ..)) => {
selected_trash_only = true
}
Some(Location::Path(path)) => {
Some(Location::Path(path))
if selected == 1
&& path.extension().and_then(|s| s.to_str()) == Some("desktop")
{
selected_desktop_entry = Some(&**path);
}
&& path.extension().and_then(|s| s.to_str()) == Some("desktop") =>
{
selected_desktop_entry = Some(&**path);
}
_ => (),
}

View file

@ -473,12 +473,12 @@ impl Op {
progress.total_bytes = metadata.as_ref().map(|m| m.len());
(ctx.on_progress)(self, &progress);
if let Some(metadata) = metadata.as_ref() {
if let Err(why) = to_file.set_permissions(metadata.permissions()).await {
// This error is not propagated upwards as some filesystems do not support setting permissions
if !matches!(why.kind(), std::io::ErrorKind::Unsupported) {
tracing::warn!(?why, "failed to set permissions for {}", self.to.display(),);
}
if let Some(metadata) = metadata.as_ref()
&& let Err(why) = to_file.set_permissions(metadata.permissions()).await
{
// This error is not propagated upwards as some filesystems do not support setting permissions
if !matches!(why.kind(), std::io::ErrorKind::Unsupported) {
tracing::warn!(?why, "failed to set permissions for {}", self.to.display(),);
}
}

View file

@ -2991,10 +2991,10 @@ impl Tab {
return None;
};
let search_items = after
.into_iter()
.iter_mut()
.enumerate()
.map(|(i, item)| (i + start, item))
.chain(until.into_iter().enumerate());
.chain(until.iter_mut().enumerate());
if forward {
Self::select_first_prefix_match(prefix_lower, search_items)
@ -3011,7 +3011,7 @@ impl Tab {
items: impl Iterator<Item = (usize, &'a mut Item)>,
) -> Option<usize> {
for (i, item) in items {
if item.name.to_lowercase().starts_with(&prefix) {
if item.name.to_lowercase().starts_with(prefix) {
item.selected = true;
return Some(i);
}
@ -4332,7 +4332,7 @@ impl Tab {
Message::ShiftPermissions(path_mode_opt, shift, bits) => match path_mode_opt {
Some((path, mode)) => commands.push(Command::SetPermissions(
path,
set_mode_part(mode, shift, bits.try_into().unwrap()),
set_mode_part(mode, shift, bits),
)),
// Shift permissions on all selected items
None => {
@ -4343,13 +4343,9 @@ impl Tab {
#[cfg(unix)]
if let (Some(path), Some(mode)) = (
item.path_opt(),
item.file_metadata()
.and_then(|metadata| Some(metadata.mode())),
item.file_metadata().map(|metadata| metadata.mode()),
) {
permissions.push((
path.clone(),
set_mode_part(mode, shift, bits.try_into().unwrap()),
));
permissions.push((path.clone(), set_mode_part(mode, shift, bits)));
}
}
commands.push(Command::SetMultiplePermissions(permissions));
@ -6415,33 +6411,31 @@ impl Tab {
let mut settings = Vec::new();
// Only allow modifying open-with if all mime types are the same
if mime_types.len() == 1 {
if let Some(mime) = mime_types
.get(0)
if mime_types.len() == 1
&& let Some(mime) = mime_types
.first()
.and_then(|(mime, _)| mime.parse::<Mime>().ok())
{
if let Some(mime_app_cache) = mime_app_cache_opt {
let mime_apps = mime_app_cache.get(&mime);
if !mime_apps.is_empty() {
let mime_closure = mime.clone();
settings.push(
widget::settings::item::builder(fl!("open-with")).control(
Element::from(
widget::dropdown(
mime_apps,
mime_apps.iter().position(|x| x.is_default),
move |index| (index, mime_closure.clone()),
)
.icons(Cow::Borrowed(mime_app_cache.icons(&mime))),
)
.map(|(index, mime)| {
let mime_app = &mime_apps[index];
Message::SetOpenWith(mime, mime_app.id.clone())
}),
),
);
}
}
&& let Some(mime_app_cache) = mime_app_cache_opt
{
let mime_apps = mime_app_cache.get(&mime);
if !mime_apps.is_empty() {
let mime_closure = mime.clone();
settings.push(
widget::settings::item::builder(fl!("open-with")).control(
Element::from(
widget::dropdown(
mime_apps,
mime_apps.iter().position(|x| x.is_default),
move |index| (index, mime_closure.clone()),
)
.icons(Cow::Borrowed(mime_app_cache.icons(&mime))),
)
.map(|(index, mime)| {
let mime_app = &mime_apps[index];
Message::SetOpenWith(mime, mime_app.id.clone())
}),
),
);
}
}

View file

@ -27,7 +27,7 @@ pub trait TrashExt {
Vec::new()
}
fn scan_search<F: Fn(SearchItem) -> bool + Sync>(callback: F, regex: &Regex) {}
fn scan_search<F: Fn(SearchItem) -> bool + Sync>(_callback: F, _regex: &Regex) {}
fn icon(icon_size: u16) -> widget::icon::Handle {
widget::icon::from_name(if Self::is_empty() {