diff --git a/waycast-plugins/src/drun.rs b/waycast-plugins/src/drun.rs index 5e79d4b..0cd36f7 100644 --- a/waycast-plugins/src/drun.rs +++ b/waycast-plugins/src/drun.rs @@ -15,11 +15,7 @@ impl LauncherListItem for DesktopEntry { id: self.id.clone(), title: self.name.to_owned(), description: { - if let Some(glib_string) = &self.description { - Some(glib_string.to_string().to_owned()) - } else { - None - } + self.description.as_ref().map(|glib_string| glib_string.to_string().to_owned()) }, icon: { if let Some(icon) = &self.icon { @@ -57,11 +53,11 @@ pub fn get_desktop_entries() -> Vec { let mut entries = Vec::new(); for i in gio::AppInfo::all() { - let info: gio::DesktopAppInfo; - match i.downcast_ref::() { - Some(inf) => info = inf.to_owned(), + + let info: gio::DesktopAppInfo = match i.downcast_ref::() { + Some(inf) => inf.to_owned(), None => continue, - } + }; if !info.should_show() { continue; } @@ -83,6 +79,12 @@ pub fn get_desktop_entries() -> Vec { pub struct DrunPlugin; +impl Default for DrunPlugin { + fn default() -> Self { + Self::new() + } +} + impl DrunPlugin { pub fn new() -> Self { DrunPlugin diff --git a/waycast-plugins/src/file_search.rs b/waycast-plugins/src/file_search.rs index db99826..fedadb1 100644 --- a/waycast-plugins/src/file_search.rs +++ b/waycast-plugins/src/file_search.rs @@ -18,9 +18,9 @@ struct FileEntry { impl FileEntry { fn from(entry: DirEntry) -> Self { - return FileEntry { + FileEntry { path: entry.into_path(), - }; + } } } @@ -82,10 +82,8 @@ pub fn default_search_list() -> Vec { ud.video_dir(), ]; - for d in user_dirs { - if let Some(path) = d { - paths.push(path.to_path_buf()); - } + for path in user_dirs.into_iter().flatten() { + paths.push(path.to_path_buf()); } return paths; @@ -101,6 +99,12 @@ pub struct FileSearchPlugin { files: Arc>>, } +impl Default for FileSearchPlugin { + fn default() -> Self { + Self::new() + } +} + impl FileSearchPlugin { pub fn new() -> Self { FileSearchPlugin {