Skip to content

Commit 37ec54b

Browse files
authored
Fix clippy collapsible match warning (#989)
1 parent 1ba220a commit 37ec54b

5 files changed

Lines changed: 9 additions & 9 deletions

File tree

lyric_finder/src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,8 @@ mod parse {
249249
}
250250

251251
match &node.data {
252-
NodeData::Text { contents } => {
253-
if should_parse {
254-
s.push_str(&contents.borrow().to_string());
255-
}
252+
NodeData::Text { contents } if should_parse => {
253+
s.push_str(&contents.borrow().to_string());
256254
}
257255
NodeData::Element { ref name, .. } => {
258256
if let expanded_name!(html "br") = name.expanded() {

spotify_player/src/event/page.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@ fn handle_command_for_library_page(
121121
// Sort albums alphabetically
122122
data.user_data
123123
.saved_albums
124-
.sort_by(|x, y| x.name.to_lowercase().cmp(&y.name.to_lowercase()));
124+
.sort_by_key(|x| x.name.to_lowercase());
125125

126126
// Sort artists alphabetically
127127
data.user_data
128128
.followed_artists
129-
.sort_by(|x, y| x.name.to_lowercase().cmp(&y.name.to_lowercase()));
129+
.sort_by_key(|x| x.name.to_lowercase());
130130
}
131131

132132
if command == Command::SortLibraryByRecent {
@@ -155,7 +155,7 @@ fn handle_command_for_library_page(
155155
// Sort albums by recent addition
156156
data.user_data
157157
.saved_albums
158-
.sort_by(|a, b| b.added_at.cmp(&a.added_at));
158+
.sort_by_key(|a| std::cmp::Reverse(a.added_at));
159159
}
160160

161161
match focus_state {

spotify_player/src/event/popup.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ pub fn handle_key_sequence_for_popup(
2727
ui,
2828
);
2929
}
30+
// can't use match guard: the match holds an immutable borrow of ui
31+
#[allow(clippy::collapsible_match)]
3032
PopupState::UserPlaylistList(..) => {
3133
if handle_key_sequence_for_playlist_search_popup(key_sequence, ui) {
3234
return Ok(true);

spotify_player/src/media_control.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ pub fn start_event_watcher(
142142
// The below refresh duration should be no less than 1s to avoid **overloading** linux dbus
143143
// handler provided by the souvlaki library, which only handles an event every 1s.
144144
// [1]: https://github.com/Sinono3/souvlaki/blob/b4d47bb2797ffdd625c17192df640510466762e1/src/platform/linux/mod.rs#L450
145-
let refresh_duration = std::time::Duration::from_millis(1000);
145+
let refresh_duration = std::time::Duration::from_secs(1);
146146
let mut info = String::new();
147147
loop {
148148
update_control_metadata(state, &mut controls, &mut info)?;

spotify_player/src/state/data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub enum FileCacheKey {
2424

2525
/// default time-to-live cache duration
2626
pub static TTL_CACHE_DURATION: LazyLock<std::time::Duration> =
27-
LazyLock::new(|| std::time::Duration::from_secs(60 * 60));
27+
LazyLock::new(|| std::time::Duration::from_hours(1));
2828

2929
/// the application's data
3030
pub struct AppData {

0 commit comments

Comments
 (0)