diff --git a/plugins/src/calc/mod.rs b/plugins/src/calc/mod.rs index 3e6937b..732c60b 100644 --- a/plugins/src/calc/mod.rs +++ b/plugins/src/calc/mod.rs @@ -237,7 +237,7 @@ fn extract_value(expression: &str) -> &str { .map(|p| p + 1) .or_else(|| expression.rfind('≈').map(|p| p + 3)) .map(|pos| expression[pos..].trim()) - .unwrap_or(&expression) + .unwrap_or(expression) } #[cfg(test)] diff --git a/plugins/src/files/mod.rs b/plugins/src/files/mod.rs index 80afb63..c41d0b1 100644 --- a/plugins/src/files/mod.rs +++ b/plugins/src/files/mod.rs @@ -97,10 +97,8 @@ impl App { let search_path = if path.is_dir() { Some(path.as_path()) - } else if let Some(parent) = path.parent() { - Some(parent) } else { - None + path.parent() }; if let Some(parent) = search_path { diff --git a/plugins/src/pulse/mod.rs b/plugins/src/pulse/mod.rs index b61fb43..fb3fe3d 100644 --- a/plugins/src/pulse/mod.rs +++ b/plugins/src/pulse/mod.rs @@ -113,14 +113,9 @@ fn filter<'a>( selections: &'a [Selection], query: &'a str, ) -> impl Iterator + 'a { - selections.iter().filter_map(move |selection| { - if selection.name.to_ascii_lowercase().contains(query) + selections.iter().filter(move |selection| { + selection.name.to_ascii_lowercase().contains(query) || selection.description.to_ascii_lowercase().contains(query) - { - Some(selection) - } else { - None - } }) } diff --git a/plugins/src/web/mod.rs b/plugins/src/web/mod.rs index 555cba9..66c25db 100644 --- a/plugins/src/web/mod.rs +++ b/plugins/src/web/mod.rs @@ -3,7 +3,7 @@ use std::borrow::Cow; use std::io; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::time::Duration; use futures_lite::StreamExt; @@ -135,14 +135,15 @@ impl App { } } - async fn fetch_icon_in_background(&self, url: Url, favicon_path: &PathBuf) { + async fn fetch_icon_in_background(&self, url: Url, favicon_path: &Path) { let client = self.client.clone(); let domain = url .domain() .map(|domain| domain.to_string()) .expect("url have no domain"); - let favicon_path = favicon_path.clone(); + + let favicon_path = favicon_path.to_path_buf(); smol::spawn(async move { let favicon_url = favicon_url_from_page_source(&domain, &client) @@ -185,7 +186,7 @@ fn build_query(definition: &Definition, query: &str) -> String { [prefix, &*definition.query, &*urlencoding::encode(query)].concat() } -async fn fetch_favicon(url: &str, favicon_path: &PathBuf, client: &HttpClient) -> Option> { +async fn fetch_favicon(url: &str, favicon_path: &Path, client: &HttpClient) -> Option> { let response = client.get_async(url).await; match response { Err(err) => { @@ -234,7 +235,7 @@ async fn favicon_url_from_page_source(domain: &str, client: &HttpClient) -> Opti if !icon_url.starts_with("https://") { format!("https://{}{}", domain, icon_url) } else { - icon_url.into() + icon_url } }), Err(_err) => None, @@ -257,7 +258,7 @@ fn parse_favicon(html: &str) -> Option { if let Some(idx) = idx { let start = idx + 6; let html = &html[start..]; - let end = html.find("\""); + let end = html.find('"'); if let Some(end) = end { let icon_uri = &html[..end]; diff --git a/service/src/lib.rs b/service/src/lib.rs index 64b8917..81e7d0f 100644 --- a/service/src/lib.rs +++ b/service/src/lib.rs @@ -112,7 +112,7 @@ impl + Unpin> Service { service_tx.clone(), plugins::help::CONFIG, Some(Regex::new(plugins::help::REGEX.as_ref()).expect("failed to compile help regex")), - move |id, tx| HelpPlugin::new(id, tx), + HelpPlugin::new, ); let f1 = request_handler(input, service_tx);