style: fix 1.67 clippy warnings

This commit is contained in:
Jake Stanger 2023-01-28 14:40:31 +00:00
parent 90cd078973
commit eb30105fc2
No known key found for this signature in database
GPG Key ID: C51FC8F9CB0BEA61
6 changed files with 19 additions and 24 deletions

View File

@ -18,9 +18,9 @@ impl Display for Compositor {
f,
"{}",
match self {
Compositor::Sway => "Sway",
Compositor::Hyprland => "Hyprland",
Compositor::Unsupported => "Unsupported",
Self::Sway => "Sway",
Self::Hyprland => "Hyprland",
Self::Unsupported => "Unsupported",
}
)
}
@ -44,9 +44,9 @@ impl Compositor {
let current = Self::get_current();
debug!("Getting workspace client for: {current}");
match current {
Compositor::Sway => Ok(sway::get_sub_client()),
Compositor::Hyprland => Ok(hyprland::get_client()),
Compositor::Unsupported => Err(Report::msg("Unsupported compositor")
Self::Sway => Ok(sway::get_sub_client()),
Self::Hyprland => Ok(hyprland::get_client()),
Self::Unsupported => Err(Report::msg("Unsupported compositor")
.note("Currently workspaces are only supported by Sway and Hyprland")),
}
}

View File

@ -58,7 +58,7 @@ impl GlobalHandler<ZwlrForeignToplevelManagerV1> for ToplevelHandler {
if inner.registry.is_none() {
inner.registry = Some(registry);
}
if let LazyGlobal::Unknown = inner.manager {
if matches!(inner.manager, LazyGlobal::Unknown) {
inner.manager = LazyGlobal::Seen { id, version }
} else {
warn!(

View File

@ -101,8 +101,7 @@ fn get_icon_location(theme: &IconTheme, app_id: &str, size: i32) -> Option<IconL
return match dirs::data_dir() {
Some(dir) => {
let path = dir.join(format!(
"icons/hicolor/32x32/apps/steam_icon_{}.png",
steam_id
"icons/hicolor/32x32/apps/steam_icon_{steam_id}.png"
));
return Some(IconLocation::File(path));

View File

@ -1,5 +1,6 @@
use crate::clients::music::{self, MusicClient, PlayerState, Status, Track};
use crate::clients::music::{self, MusicClient, PlayerState, PlayerUpdate, Status, Track};
use crate::config::CommonConfig;
use crate::error::ERR_CHANNEL_SEND;
use crate::modules::{Module, ModuleInfo, ModuleUpdateEvent, ModuleWidget, WidgetContext};
use crate::popup::Popup;
use crate::try_send;
@ -15,7 +16,6 @@ use std::path::PathBuf;
use std::sync::Arc;
use std::time::Duration;
use tokio::spawn;
use tokio::sync::mpsc;
use tokio::sync::mpsc::{Receiver, Sender};
use tracing::error;
@ -122,7 +122,7 @@ fn format_time(duration: Duration) -> String {
let minutes = (time / 60) % 60;
let seconds = time % 60;
format!("{:0>2}:{:0>2}", minutes, seconds)
format!("{minutes:0>2}:{seconds:0>2}")
}
/// Extracts the formatting tokens from a formatting string
@ -395,7 +395,7 @@ impl Module<Button> for MusicModule {
Some(Ok(pixbuf)) => album_image.set_from_pixbuf(Some(&pixbuf)),
Some(Err(err)) => {
error!("{:?}", err);
album_image.set_from_pixbuf(None)
album_image.set_from_pixbuf(None);
}
None => album_image.set_from_pixbuf(None),
};
@ -464,8 +464,7 @@ fn replace_tokens(
let mut compiled_string = format_string.to_string();
for token in tokens {
let value = get_token_value(song, status, icons, token);
compiled_string =
compiled_string.replace(format!("{{{}}}", token).as_str(), value.as_str());
compiled_string = compiled_string.replace(format!("{{{token}}}").as_str(), value.as_str());
}
compiled_string
}
@ -479,7 +478,7 @@ fn get_token_value(song: &Track, status: &Status, icons: &Icons, token: &str) ->
PlayerState::Playing => Some(&icons.play),
PlayerState::Paused => Some(&icons.pause),
}
.map(|s| s.to_string()),
.map(std::string::ToString::to_string),
"title" => song.title.clone(),
"album" => song.album.clone(),
"artist" => song.artist.clone(),

View File

@ -250,7 +250,7 @@ fn refresh_memory_tokens(format_info: &mut HashMap<String, String>, sys: &mut Sy
);
format_info.insert(
String::from("memory_percent"),
format!("{:0>2.0}", memory_percent),
format!("{memory_percent:0>2.0}"),
);
let used_swap = sys.used_swap();
@ -280,10 +280,7 @@ fn refresh_cpu_tokens(format_info: &mut HashMap<String, String>, sys: &mut Syste
let cpu_info = sys.global_cpu_info();
let cpu_percent = cpu_info.cpu_usage();
format_info.insert(
String::from("cpu_percent"),
format!("{:0>2.0}", cpu_percent),
);
format_info.insert(String::from("cpu_percent"), format!("{cpu_percent:0>2.0}"));
}
fn refresh_temp_tokens(format_info: &mut HashMap<String, String>, sys: &mut System) {

View File

@ -38,7 +38,7 @@ impl From<&str> for ScriptMode {
"watch" | "w" => Self::Watch,
_ => {
warn!("Invalid script mode: '{str}', falling back to polling");
ScriptMode::Poll
Self::Poll
}
}
}
@ -56,8 +56,8 @@ impl Display for ScriptMode {
f,
"{}",
match self {
ScriptMode::Poll => "poll",
ScriptMode::Watch => "watch",
Self::Poll => "poll",
Self::Watch => "watch",
}
)
}