chore: update to Rust 2024 edition

This commit is contained in:
mayor
2026-01-04 20:08:16 +01:00
committed by Michel de Graaf
parent f7ebcccdd3
commit 16c8a4bde9
9 changed files with 39 additions and 55 deletions
+10 -16
View File
@@ -113,11 +113,10 @@ impl FileSelector {
Duration::from_millis(100)
};
if poll(timeout)? {
if let Event::Key(key) = event::read()? {
if poll(timeout)?
&& let Event::Key(key) = event::read()? {
self.handle_key(key);
}
}
}
Ok((terminal, self.selected_indices.iter().copied().collect()))
@@ -157,8 +156,8 @@ impl FileSelector {
}
fn toggle_selection(&mut self) {
if let Some(filtered_idx) = self.state.selected() {
if let Some(&original_idx) = self.filtered_indices.get(filtered_idx)
if let Some(filtered_idx) = self.state.selected()
&& let Some(&original_idx) = self.filtered_indices.get(filtered_idx)
{
if self.selected_indices.contains(&original_idx) {
self.selected_indices.remove(&original_idx);
@@ -166,7 +165,6 @@ impl FileSelector {
self.selected_indices.insert(original_idx);
}
}
}
}
fn handle_key(&mut self, key: KeyEvent) {
@@ -194,15 +192,13 @@ impl FileSelector {
}
KeyCode::Enter => {
// If nothing selected, select the current item under cursor
if self.selected_indices.is_empty() {
if let Some(filtered_idx) = self.state.selected() {
if let Some(&original_idx) =
if self.selected_indices.is_empty()
&& let Some(filtered_idx) = self.state.selected()
&& let Some(&original_idx) =
self.filtered_indices.get(filtered_idx)
{
self.selected_indices.insert(original_idx);
}
}
}
self.should_exit = true;
}
KeyCode::Up | KeyCode::Down => {
@@ -238,15 +234,13 @@ impl FileSelector {
}
KeyCode::Enter => {
// If nothing selected, select the current item under cursor
if self.selected_indices.is_empty() {
if let Some(filtered_idx) = self.state.selected() {
if let Some(&original_idx) =
if self.selected_indices.is_empty()
&& let Some(filtered_idx) = self.state.selected()
&& let Some(&original_idx) =
self.filtered_indices.get(filtered_idx)
{
self.selected_indices.insert(original_idx);
}
}
}
self.should_exit = true;
}
KeyCode::Esc | KeyCode::Char('q') => {
+4 -6
View File
@@ -81,8 +81,8 @@ impl MultiDownloadProgress {
// Poll all receivers for status updates
let mut need_start_next = false;
for download_entry in &mut self.downloads {
if let Some(receiver) = &download_entry.receiver {
if let Ok(status) = receiver.try_recv() {
if let Some(receiver) = &download_entry.receiver
&& let Ok(status) = receiver.try_recv() {
let was_active = !download_entry.download.is_finished();
download_entry.download.status = status;
let is_finished = download_entry.download.is_finished();
@@ -94,7 +94,6 @@ impl MultiDownloadProgress {
need_start_next = true;
}
}
}
}
// Start next batch after iteration completes
@@ -103,11 +102,10 @@ impl MultiDownloadProgress {
}
// Handle keyboard input
if poll(Duration::from_millis(100))? {
if let Event::Key(key) = event::read()? {
if poll(Duration::from_millis(100))?
&& let Event::Key(key) = event::read()? {
self.handle_key(key);
}
}
// Exit when user cancels or all downloads finished
if self.should_exit || self.all_finished() {
+8 -12
View File
@@ -519,8 +519,8 @@ impl MainTui {
let (col, row) = (mouse.column, mouse.row);
// Check if click is within searches pane
if let Some(area) = self.state.searches_pane_area {
if col >= area.x
if let Some(area) = self.state.searches_pane_area
&& col >= area.x
&& col < area.x + area.width
&& row >= area.y
&& row < area.y + area.height
@@ -528,11 +528,10 @@ impl MainTui {
self.state.focused_pane = FocusedPane::Searches;
return Ok(());
}
}
// Check if click is within results pane
if let Some(area) = self.state.results_pane_area {
if col >= area.x
if let Some(area) = self.state.results_pane_area
&& col >= area.x
&& col < area.x + area.width
&& row >= area.y
&& row < area.y + area.height
@@ -540,11 +539,10 @@ impl MainTui {
self.state.focused_pane = FocusedPane::Results;
return Ok(());
}
}
// Check if click is within downloads pane
if let Some(area) = self.state.downloads_pane_area {
if col >= area.x
if let Some(area) = self.state.downloads_pane_area
&& col >= area.x
&& col < area.x + area.width
&& row >= area.y
&& row < area.y + area.height
@@ -552,7 +550,6 @@ impl MainTui {
self.state.focused_pane = FocusedPane::Downloads;
return Ok(());
}
}
}
Ok(())
@@ -749,15 +746,14 @@ impl MainTui {
}
// Update selected search if this is the active one
if let Some(selected_idx) = selected_search_index {
if selected_idx == idx {
if let Some(selected_idx) = selected_search_index
&& selected_idx == idx {
self.state.results_items = search.results.clone();
self.state.results_filtered_items =
search.results.clone();
self.state.results_filtered_indices =
(0..search.results.len()).collect();
}
}
}
// Mark as completed after timeout