diff options
| author | salmonik <salmonik@tuta.io> | 2026-11-02 13:02:11 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-11-02 13:02:11 +0100 |
| commit | 7683b319b851df5e66465db4916e239b788c09fa (patch) | |
| tree | 204cd95bf68c4707e5c0ad1d62471a35eadad2d3 | |
| parent | install.sh: only install the systemd service on linux (diff) | |
| download | rsplayer-7683b319b851df5e66465db4916e239b788c09fa.tar.gz rsplayer-7683b319b851df5e66465db4916e239b788c09fa.zip | |
queue: use let chains and tidy imports
| -rw-r--r-- | src/queue.rs | 12 | ||||
| -rw-r--r-- | tests/queue.rs | 7 |
2 files changed, 11 insertions, 8 deletions
diff --git a/src/queue.rs b/src/queue.rs index da79441..17f2143 100644 --- a/src/queue.rs +++ b/src/queue.rs | |||
| @@ -5,9 +5,9 @@ | |||
| 5 | * https://codeberg.org/salmonik/RSPlayer | 5 | * https://codeberg.org/salmonik/RSPlayer |
| 6 | */ | 6 | */ |
| 7 | 7 | ||
| 8 | use rand::SeedableRng; | ||
| 8 | use rand::rngs::StdRng; | 9 | use rand::rngs::StdRng; |
| 9 | use rand::seq::SliceRandom; | 10 | use rand::seq::SliceRandom; |
| 10 | use rand::SeedableRng; | ||
| 11 | use std::path::{Path, PathBuf}; | 11 | use std::path::{Path, PathBuf}; |
| 12 | 12 | ||
| 13 | #[derive(Debug, Clone, PartialEq)] | 13 | #[derive(Debug, Clone, PartialEq)] |
| @@ -315,11 +315,11 @@ impl Queue { | |||
| 315 | let mut played: Vec<Track> = Vec::new(); | 315 | let mut played: Vec<Track> = Vec::new(); |
| 316 | let mut played_idx: Vec<usize> = Vec::new(); | 316 | let mut played_idx: Vec<usize> = Vec::new(); |
| 317 | for i in 0..=current_pos { | 317 | for i in 0..=current_pos { |
| 318 | if let Some(&idx) = self.shuffled_indices.get(i) { | 318 | if let Some(&idx) = self.shuffled_indices.get(i) |
| 319 | if let Some(track) = self.tracks.get(idx) { | 319 | && let Some(track) = self.tracks.get(idx) |
| 320 | played.push(track.clone()); | 320 | { |
| 321 | played_idx.push(idx); | 321 | played.push(track.clone()); |
| 322 | } | 322 | played_idx.push(idx); |
| 323 | } | 323 | } |
| 324 | } | 324 | } |
| 325 | 325 | ||
diff --git a/tests/queue.rs b/tests/queue.rs index 67cbabf..7472195 100644 --- a/tests/queue.rs +++ b/tests/queue.rs | |||
| @@ -504,7 +504,9 @@ fn test_add_during_shuffle_survives_shuffle_off() { | |||
| 504 | q.len() | 504 | q.len() |
| 505 | ); | 505 | ); |
| 506 | assert!( | 506 | assert!( |
| 507 | q.tracks().iter().any(|t| t.path == PathBuf::from("/music/d.mp3")), | 507 | q.tracks() |
| 508 | .iter() | ||
| 509 | .any(|t| t.path == PathBuf::from("/music/d.mp3")), | ||
| 508 | "track added during shuffle was dropped when shuffle was turned off" | 510 | "track added during shuffle was dropped when shuffle was turned off" |
| 509 | ); | 511 | ); |
| 510 | } | 512 | } |
| @@ -601,7 +603,8 @@ fn test_shuffle_play_now_current_is_inserted_track() { | |||
| 601 | assert_eq!(q.position(), 1); | 603 | assert_eq!(q.position(), 1); |
| 602 | let cur = q.current().expect("queue is not empty"); | 604 | let cur = q.current().expect("queue is not empty"); |
| 603 | assert_eq!( | 605 | assert_eq!( |
| 604 | cur.path, inserted, | 606 | cur.path, |
| 607 | inserted, | ||
| 605 | "seed {}: current() after play-now is {:?}, expected {:?}; shuffled_indices={:?}", | 608 | "seed {}: current() after play-now is {:?}, expected {:?}; shuffled_indices={:?}", |
| 606 | seed, | 609 | seed, |
| 607 | cur.path, | 610 | cur.path, |
