Skip to content

Commit

Permalink
style: fix 1.67 clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeStanger committed Jan 28, 2023
1 parent 90cd078 commit eb30105
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 24 deletions.
12 changes: 6 additions & 6 deletions src/clients/compositor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
)
}
Expand All @@ -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")),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/clients/wayland/toplevel_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down
3 changes: 1 addition & 2 deletions src/icon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
13 changes: 6 additions & 7 deletions src/modules/music.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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),
};
Expand Down Expand Up @@ -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
}
Expand All @@ -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(),
Expand Down
7 changes: 2 additions & 5 deletions src/modules/sysinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions src/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand All @@ -56,8 +56,8 @@ impl Display for ScriptMode {
f,
"{}",
match self {
ScriptMode::Poll => "poll",
ScriptMode::Watch => "watch",
Self::Poll => "poll",
Self::Watch => "watch",
}
)
}
Expand Down

0 comments on commit eb30105

Please sign in to comment.