From 9b22c8f9edbcde8e992339bd115f68792c30e314 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Tue, 27 Feb 2024 09:58:22 -0700 Subject: [PATCH] Fix warnings --- src/app.rs | 36 +++++++++++------------------------- src/dialog.rs | 8 +------- src/operation.rs | 12 ++++++------ src/tab.rs | 12 +++++------- 4 files changed, 23 insertions(+), 45 deletions(-) diff --git a/src/app.rs b/src/app.rs index faf5fca..0422267 100644 --- a/src/app.rs +++ b/src/app.rs @@ -3,8 +3,7 @@ use cosmic::{ app::{message, Command, Core}, - cosmic_config::{self, CosmicConfigEntry}, - cosmic_theme, executor, + cosmic_config, cosmic_theme, executor, iced::{ event, futures::{self, SinkExt}, @@ -237,19 +236,6 @@ impl App { cosmic::app::command::set_theme(self.config.app_theme.theme()) } - fn save_config(&mut self) -> Command { - match self.config_handler { - Some(ref config_handler) => match self.config.write_entry(&config_handler) { - Ok(()) => {} - Err(err) => { - log::error!("failed to save config: {}", err); - } - }, - None => {} - } - self.update_config() - } - fn update_title(&mut self) -> Command { let (header_title, window_title) = match self.tab_model.text(self.tab_model.active()) { Some(tab_title) => ( @@ -317,7 +303,7 @@ impl App { if !self.pending_operations.is_empty() { let mut section = widget::settings::view_section(fl!("pending")); - for (id, (op, progress)) in self.pending_operations.iter().rev() { + for (_id, (op, progress)) in self.pending_operations.iter().rev() { section = section.add(widget::column::with_children(vec![ widget::text(format!("{:?}", op)).into(), widget::progress_bar(0.0..=100.0, *progress) @@ -330,7 +316,7 @@ impl App { if !self.failed_operations.is_empty() { let mut section = widget::settings::view_section(fl!("failed")); - for (id, (op, error)) in self.failed_operations.iter().rev() { + for (_id, (op, error)) in self.failed_operations.iter().rev() { section = section.add(widget::column::with_children(vec![ widget::text(format!("{:?}", op)).into(), widget::text(error).into(), @@ -341,7 +327,7 @@ impl App { if !self.complete_operations.is_empty() { let mut section = widget::settings::view_section(fl!("complete")); - for (id, op) in self.complete_operations.iter().rev() { + for (_id, op) in self.complete_operations.iter().rev() { section = section.add(widget::text(format!("{:?}", op))); } children.push(section.into()); @@ -635,10 +621,10 @@ impl Application for App { return self.update_config(); } } - Message::Copy(entity_opt) => { + Message::Copy(_entity_opt) => { log::warn!("TODO: COPY"); } - Message::Cut(entity_opt) => { + Message::Cut(_entity_opt) => { log::warn!("TODO: CUT"); } Message::Key(modifiers, key) => { @@ -668,10 +654,10 @@ impl Application for App { self.operation(Operation::Delete { paths }); } } - Message::NewFile(entity_opt) => { + Message::NewFile(_entity_opt) => { log::warn!("TODO: NEW FILE"); } - Message::NewFolder(entity_opt) => { + Message::NewFolder(_entity_opt) => { log::warn!("TODO: NEW FOLDER"); } Message::NotifyEvent(event) => { @@ -712,7 +698,7 @@ impl Application for App { log::warn!("message did not contain notify watcher"); } }, - Message::Paste(entity_opt) => { + Message::Paste(_entity_opt) => { log::warn!("TODO: PASTE"); } Message::PendingComplete(id) => { @@ -1112,10 +1098,10 @@ impl Application for App { move |mut msg_tx| async move { match pending_operation.perform(id, &mut msg_tx).await { Ok(()) => { - msg_tx.send(Message::PendingComplete(id)).await; + let _ = msg_tx.send(Message::PendingComplete(id)).await; } Err(err) => { - msg_tx + let _ = msg_tx .send(Message::PendingError(id, err.to_string())) .await; } diff --git a/src/dialog.rs b/src/dialog.rs index 8f2f0e1..051a046 100644 --- a/src/dialog.rs +++ b/src/dialog.rs @@ -12,7 +12,6 @@ use cosmic::{ subscription::{self, Subscription}, window, Event, Length, Size, }, - style, widget::{self, segmented_button}, Application, ApplicationExt, Element, }; @@ -600,12 +599,7 @@ impl Application for App { /// Creates a view after each update. fn view(&self) -> Element { - let cosmic_theme::Spacing { - space_m, - space_s, - space_xxs, - .. - } = self.core().system_theme().cosmic().spacing; + let cosmic_theme::Spacing { space_xxs, .. } = self.core().system_theme().cosmic().spacing; let mut tab_column = widget::column::with_capacity(2); tab_column = tab_column.push( diff --git a/src/operation.rs b/src/operation.rs index 45fa2d4..caee0f6 100644 --- a/src/operation.rs +++ b/src/operation.rs @@ -22,13 +22,13 @@ pub enum Operation { impl Operation { /// Perform the operation pub async fn perform(self, id: u64, msg_tx: &mut mpsc::Sender) -> Result<(), String> { - msg_tx.send(Message::PendingProgress(id, 0.0)).await; + let _ = msg_tx.send(Message::PendingProgress(id, 0.0)).await; //TODO: IF ERROR, RETURN AN Operation THAT CAN UNDO THE CURRENT STATE //TODO: SAFELY HANDLE CANCEL match self { Self::Delete { paths } => { - let mut total = paths.len(); + let total = paths.len(); let mut count = 0; for path in paths { tokio::task::spawn_blocking(|| trash::delete(path)) @@ -36,7 +36,7 @@ impl Operation { .map_err(err_str)? .map_err(err_str)?; count += 1; - msg_tx + let _ = msg_tx .send(Message::PendingProgress( id, 100.0 * (count as f32) / (total as f32), @@ -45,7 +45,7 @@ impl Operation { } } Self::Restore { paths } => { - let mut total = paths.len(); + let total = paths.len(); let mut count = 0; for path in paths { tokio::task::spawn_blocking(|| trash::os_limited::restore_all([path])) @@ -53,7 +53,7 @@ impl Operation { .map_err(err_str)? .map_err(err_str)?; count += 1; - msg_tx + let _ = msg_tx .send(Message::PendingProgress( id, 100.0 * (count as f32) / (total as f32), @@ -66,7 +66,7 @@ impl Operation { } } - msg_tx.send(Message::PendingProgress(id, 100.0)).await; + let _ = msg_tx.send(Message::PendingProgress(id, 100.0)).await; Ok(()) } diff --git a/src/tab.rs b/src/tab.rs index 5d73a56..06c9eb0 100644 --- a/src/tab.rs +++ b/src/tab.rs @@ -25,7 +25,6 @@ use std::{ fmt, fs::{self, Metadata}, path::PathBuf, - process, time::{Duration, Instant}, }; @@ -566,7 +565,7 @@ impl Tab { }; println!("{:?}", rect); - for (i, item) in items.iter_mut().enumerate() { + for (_i, item) in items.iter_mut().enumerate() { item.selected = false; //TODO } @@ -1125,7 +1124,7 @@ impl Tab { mouse_area::MouseArea::new(widget::container(item_view).height(Length::Fill)) .on_drag(move |point_opt| Message::Drag(point_opt)) .on_press(move |_point_opt| Message::Click(None)) - .on_release(move |point_opt| Message::Drag(None)) + .on_release(move |_point_opt| Message::Drag(None)) .on_back_press(move |_point_opt| Message::GoPrevious) .on_forward_press(move |_point_opt| Message::GoNext) .show_drag_box(true); @@ -1240,12 +1239,11 @@ mod tests { use tempfile::TempDir; use test_log::test; - use super::{scan_path, Item, Location, Message, Tab}; + use super::{scan_path, Location, Message, Tab}; use crate::{ app::test_utils::{ - assert_eq_tab_path, assert_eq_tab_path_contents, empty_fs, eq_path_item, filter_dirs, - read_dir_sorted, simple_fs, sort_files, tab_click_new, NAME_LEN, NUM_DIRS, NUM_FILES, - NUM_HIDDEN, NUM_NESTED, + assert_eq_tab_path, empty_fs, eq_path_item, filter_dirs, read_dir_sorted, simple_fs, + tab_click_new, NAME_LEN, NUM_DIRS, NUM_FILES, NUM_HIDDEN, NUM_NESTED, }, config::{IconSizes, TabConfig}, };