1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-07-01 18:51:04 +02:00

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, f,
"{}", "{}",
match self { match self {
Compositor::Sway => "Sway", Self::Sway => "Sway",
Compositor::Hyprland => "Hyprland", Self::Hyprland => "Hyprland",
Compositor::Unsupported => "Unsupported", Self::Unsupported => "Unsupported",
} }
) )
} }
@ -44,9 +44,9 @@ impl Compositor {
let current = Self::get_current(); let current = Self::get_current();
debug!("Getting workspace client for: {current}"); debug!("Getting workspace client for: {current}");
match current { match current {
Compositor::Sway => Ok(sway::get_sub_client()), Self::Sway => Ok(sway::get_sub_client()),
Compositor::Hyprland => Ok(hyprland::get_client()), Self::Hyprland => Ok(hyprland::get_client()),
Compositor::Unsupported => Err(Report::msg("Unsupported compositor") Self::Unsupported => Err(Report::msg("Unsupported compositor")
.note("Currently workspaces are only supported by Sway and Hyprland")), .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() { if inner.registry.is_none() {
inner.registry = Some(registry); inner.registry = Some(registry);
} }
if let LazyGlobal::Unknown = inner.manager { if matches!(inner.manager, LazyGlobal::Unknown) {
inner.manager = LazyGlobal::Seen { id, version } inner.manager = LazyGlobal::Seen { id, version }
} else { } else {
warn!( 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() { return match dirs::data_dir() {
Some(dir) => { Some(dir) => {
let path = dir.join(format!( let path = dir.join(format!(
"icons/hicolor/32x32/apps/steam_icon_{}.png", "icons/hicolor/32x32/apps/steam_icon_{steam_id}.png"
steam_id
)); ));
return Some(IconLocation::File(path)); 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::config::CommonConfig;
use crate::error::ERR_CHANNEL_SEND;
use crate::modules::{Module, ModuleInfo, ModuleUpdateEvent, ModuleWidget, WidgetContext}; use crate::modules::{Module, ModuleInfo, ModuleUpdateEvent, ModuleWidget, WidgetContext};
use crate::popup::Popup; use crate::popup::Popup;
use crate::try_send; use crate::try_send;
@ -15,7 +16,6 @@ use std::path::PathBuf;
use std::sync::Arc; use std::sync::Arc;
use std::time::Duration; use std::time::Duration;
use tokio::spawn; use tokio::spawn;
use tokio::sync::mpsc;
use tokio::sync::mpsc::{Receiver, Sender}; use tokio::sync::mpsc::{Receiver, Sender};
use tracing::error; use tracing::error;
@ -122,7 +122,7 @@ fn format_time(duration: Duration) -> String {
let minutes = (time / 60) % 60; let minutes = (time / 60) % 60;
let seconds = time % 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 /// 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(Ok(pixbuf)) => album_image.set_from_pixbuf(Some(&pixbuf)),
Some(Err(err)) => { Some(Err(err)) => {
error!("{:?}", err); error!("{:?}", err);
album_image.set_from_pixbuf(None) album_image.set_from_pixbuf(None);
} }
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(); let mut compiled_string = format_string.to_string();
for token in tokens { for token in tokens {
let value = get_token_value(song, status, icons, token); let value = get_token_value(song, status, icons, token);
compiled_string = compiled_string = compiled_string.replace(format!("{{{token}}}").as_str(), value.as_str());
compiled_string.replace(format!("{{{}}}", token).as_str(), value.as_str());
} }
compiled_string compiled_string
} }
@ -479,7 +478,7 @@ fn get_token_value(song: &Track, status: &Status, icons: &Icons, token: &str) ->
PlayerState::Playing => Some(&icons.play), PlayerState::Playing => Some(&icons.play),
PlayerState::Paused => Some(&icons.pause), PlayerState::Paused => Some(&icons.pause),
} }
.map(|s| s.to_string()), .map(std::string::ToString::to_string),
"title" => song.title.clone(), "title" => song.title.clone(),
"album" => song.album.clone(), "album" => song.album.clone(),
"artist" => song.artist.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( format_info.insert(
String::from("memory_percent"), String::from("memory_percent"),
format!("{:0>2.0}", memory_percent), format!("{memory_percent:0>2.0}"),
); );
let used_swap = sys.used_swap(); 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_info = sys.global_cpu_info();
let cpu_percent = cpu_info.cpu_usage(); let cpu_percent = cpu_info.cpu_usage();
format_info.insert( format_info.insert(String::from("cpu_percent"), format!("{cpu_percent:0>2.0}"));
String::from("cpu_percent"),
format!("{:0>2.0}", cpu_percent),
);
} }
fn refresh_temp_tokens(format_info: &mut HashMap<String, String>, sys: &mut System) { 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, "watch" | "w" => Self::Watch,
_ => { _ => {
warn!("Invalid script mode: '{str}', falling back to polling"); warn!("Invalid script mode: '{str}', falling back to polling");
ScriptMode::Poll Self::Poll
} }
} }
} }
@ -56,8 +56,8 @@ impl Display for ScriptMode {
f, f,
"{}", "{}",
match self { match self {
ScriptMode::Poll => "poll", Self::Poll => "poll",
ScriptMode::Watch => "watch", Self::Watch => "watch",
} }
) )
} }