From e04237b92869c3f69f34c2c55722a29f5fa6e631 Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Thu, 2 Sep 2021 21:13:57 +0200 Subject: [PATCH] Use format string with panic --- src/config.rs | 2 +- src/doublemempool.rs | 4 ++-- src/widgets/audio/alsa_sound.rs | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/config.rs b/src/config.rs index 9fd2a60..59d4ac5 100644 --- a/src/config.rs +++ b/src/config.rs @@ -345,6 +345,6 @@ impl Default for Config { fn get_font<'a>(name: &str, map: &'a FontMap) -> FontRef<'a> { match map.get(name) { Some(f) => f, - None => panic!(format!("Font {} is missing from the config", name)), + None => panic!("Font {} is missing from the config", name), } } diff --git a/src/doublemempool.rs b/src/doublemempool.rs index 8ab6975..d6871f0 100644 --- a/src/doublemempool.rs +++ b/src/doublemempool.rs @@ -209,9 +209,9 @@ fn create_shm_fd() -> io::Result { Err(nix::Error::Sys(errno)) => match unistd::close(fd) { Ok(_) => return Err(io::Error::from(errno)), Err(nix::Error::Sys(errno)) => return Err(io::Error::from(errno)), - Err(err) => panic!(err), + Err(err) => panic!("{}", err), }, - Err(err) => panic!(err), + Err(err) => panic!("{}", err), }, Err(nix::Error::Sys(Errno::EEXIST)) => { // If a file with that handle exists then change the handle diff --git a/src/widgets/audio/alsa_sound.rs b/src/widgets/audio/alsa_sound.rs index 728aff2..76f0e3d 100644 --- a/src/widgets/audio/alsa_sound.rs +++ b/src/widgets/audio/alsa_sound.rs @@ -99,7 +99,7 @@ impl BarWidgetImpl for Alsa { fn value(&self) -> f32 { match self.get_master_volume() { Ok(v) => v, - Err(e) => panic!(e), + Err(e) => panic!("{}", e), } } fn color(&self) -> Color { @@ -107,12 +107,12 @@ impl BarWidgetImpl for Alsa { } fn inc(&mut self, diff: f32) { if let Err(e) = self.inc_master_volume(diff) { - panic!(e) + panic!("{}", e) } } fn set(&mut self, abs: f32) { if let Err(e) = self.set_master_volume(abs) { - panic!(e) + panic!("{}", e) } } fn toggle(&mut self) {}