mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-07-01 18:51:04 +02:00
refactor: various changes based on rust 1.65 clippy
This commit is contained in:
parent
c48029664d
commit
ff17ec1996
7 changed files with 59 additions and 64 deletions
|
@ -81,18 +81,20 @@ impl Module<gtk::Box> for LauncherModule {
|
|||
tx: Sender<ModuleUpdateEvent<Self::SendMessage>>,
|
||||
mut rx: Receiver<Self::ReceiveMessage>,
|
||||
) -> crate::Result<()> {
|
||||
let items = match &self.favorites {
|
||||
Some(favorites) => favorites
|
||||
.iter()
|
||||
.map(|app_id| {
|
||||
(
|
||||
app_id.to_string(),
|
||||
Item::new(app_id.to_string(), OpenState::Closed, true),
|
||||
)
|
||||
})
|
||||
.collect::<IndexMap<_, _>>(),
|
||||
None => IndexMap::new(),
|
||||
};
|
||||
let items = self
|
||||
.favorites
|
||||
.as_ref()
|
||||
.map_or_else(IndexMap::new, |favorites| {
|
||||
favorites
|
||||
.iter()
|
||||
.map(|app_id| {
|
||||
(
|
||||
app_id.to_string(),
|
||||
Item::new(app_id.to_string(), OpenState::Closed, true),
|
||||
)
|
||||
})
|
||||
.collect::<IndexMap<_, _>>()
|
||||
});
|
||||
|
||||
let items = Arc::new(Mutex::new(items));
|
||||
|
||||
|
|
|
@ -141,10 +141,9 @@ async fn try_get_mpd_conn(host: &str) -> Result<Connection, MpdProtocolError> {
|
|||
fn is_unix_socket(host: &str) -> bool {
|
||||
let path = PathBuf::from(host);
|
||||
path.exists()
|
||||
&& match path.metadata() {
|
||||
Ok(metadata) => metadata.file_type().is_socket(),
|
||||
Err(_) => false,
|
||||
}
|
||||
&& path
|
||||
.metadata()
|
||||
.map_or(false, |metadata| metadata.file_type().is_socket())
|
||||
}
|
||||
|
||||
async fn connect_unix(host: &str) -> Result<Connection, MpdProtocolError> {
|
||||
|
|
|
@ -97,10 +97,7 @@ fn default_music_dir() -> PathBuf {
|
|||
/// Attempts to read the first value for a tag
|
||||
/// (since the MPD client returns a vector of tags, or None)
|
||||
pub fn try_get_first_tag(vec: Option<&Vec<String>>) -> Option<&str> {
|
||||
match vec {
|
||||
Some(vec) => vec.first().map(String::as_str),
|
||||
None => None,
|
||||
}
|
||||
vec.and_then(|vec| vec.first().map(String::as_str))
|
||||
}
|
||||
|
||||
/// Formats a duration given in seconds
|
||||
|
@ -369,11 +366,14 @@ impl Module<Button> for MpdModule {
|
|||
.join("cover.jpg"),
|
||||
);
|
||||
|
||||
if let Ok(pixbuf) = Pixbuf::from_file_at_scale(cover_path, 128, 128, true) {
|
||||
album_image.set_from_pixbuf(Some(&pixbuf));
|
||||
} else {
|
||||
album_image.set_from_pixbuf(None);
|
||||
}
|
||||
Pixbuf::from_file_at_scale(cover_path, 128, 128, true).map_or_else(
|
||||
|_| {
|
||||
album_image.set_from_pixbuf(None);
|
||||
},
|
||||
|pixbuf| {
|
||||
album_image.set_from_pixbuf(Some(&pixbuf));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
title_label
|
||||
|
|
|
@ -359,7 +359,7 @@ fn refresh_disk_tokens(format_info: &mut HashMap<String, String>, sys: &mut Syst
|
|||
let key = disk
|
||||
.mount_point()
|
||||
.to_str()
|
||||
.map(|s| s.replace('{', "").replace('}', ""));
|
||||
.map(|s| s.replace(['{', '}'], ""));
|
||||
|
||||
if let Some(key) = key {
|
||||
let total = disk.total_space();
|
||||
|
|
|
@ -23,7 +23,7 @@ pub struct TrayModule;
|
|||
fn get_icon(item: &StatusNotifierItem) -> Option<Image> {
|
||||
item.icon_theme_path.as_ref().and_then(|path| {
|
||||
let theme = IconTheme::new();
|
||||
theme.append_search_path(&path);
|
||||
theme.append_search_path(path);
|
||||
|
||||
item.icon_name.as_ref().and_then(|icon_name| {
|
||||
let icon_info = theme.lookup_icon(icon_name, 16, IconLookupFlags::empty());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue