chore: Apply Clippy lint fixes

This commit is contained in:
Michael Aaron Murphy 2021-10-29 18:02:07 +02:00
parent 5a4b829e17
commit e6a2babceb
5 changed files with 12 additions and 18 deletions

View file

@ -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)]

View file

@ -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 {

View file

@ -113,14 +113,9 @@ fn filter<'a>(
selections: &'a [Selection],
query: &'a str,
) -> impl Iterator<Item = &'a Selection> + '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
}
})
}

View file

@ -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<Vec<u8>> {
async fn fetch_favicon(url: &str, favicon_path: &Path, client: &HttpClient) -> Option<Vec<u8>> {
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<String> {
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];

View file

@ -112,7 +112,7 @@ impl<O: futures::Sink<Response> + Unpin> Service<O> {
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);