chore: Apply Clippy lint fixes
This commit is contained in:
parent
5a4b829e17
commit
e6a2babceb
5 changed files with 12 additions and 18 deletions
|
|
@ -237,7 +237,7 @@ fn extract_value(expression: &str) -> &str {
|
||||||
.map(|p| p + 1)
|
.map(|p| p + 1)
|
||||||
.or_else(|| expression.rfind('≈').map(|p| p + 3))
|
.or_else(|| expression.rfind('≈').map(|p| p + 3))
|
||||||
.map(|pos| expression[pos..].trim())
|
.map(|pos| expression[pos..].trim())
|
||||||
.unwrap_or(&expression)
|
.unwrap_or(expression)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
||||||
|
|
@ -97,10 +97,8 @@ impl App {
|
||||||
|
|
||||||
let search_path = if path.is_dir() {
|
let search_path = if path.is_dir() {
|
||||||
Some(path.as_path())
|
Some(path.as_path())
|
||||||
} else if let Some(parent) = path.parent() {
|
|
||||||
Some(parent)
|
|
||||||
} else {
|
} else {
|
||||||
None
|
path.parent()
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(parent) = search_path {
|
if let Some(parent) = search_path {
|
||||||
|
|
|
||||||
|
|
@ -113,14 +113,9 @@ fn filter<'a>(
|
||||||
selections: &'a [Selection],
|
selections: &'a [Selection],
|
||||||
query: &'a str,
|
query: &'a str,
|
||||||
) -> impl Iterator<Item = &'a Selection> + 'a {
|
) -> impl Iterator<Item = &'a Selection> + 'a {
|
||||||
selections.iter().filter_map(move |selection| {
|
selections.iter().filter(move |selection| {
|
||||||
if selection.name.to_ascii_lowercase().contains(query)
|
selection.name.to_ascii_lowercase().contains(query)
|
||||||
|| selection.description.to_ascii_lowercase().contains(query)
|
|| selection.description.to_ascii_lowercase().contains(query)
|
||||||
{
|
|
||||||
Some(selection)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::path::PathBuf;
|
use std::path::{Path, PathBuf};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use futures_lite::StreamExt;
|
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 client = self.client.clone();
|
||||||
|
|
||||||
let domain = url
|
let domain = url
|
||||||
.domain()
|
.domain()
|
||||||
.map(|domain| domain.to_string())
|
.map(|domain| domain.to_string())
|
||||||
.expect("url have no domain");
|
.expect("url have no domain");
|
||||||
let favicon_path = favicon_path.clone();
|
|
||||||
|
let favicon_path = favicon_path.to_path_buf();
|
||||||
|
|
||||||
smol::spawn(async move {
|
smol::spawn(async move {
|
||||||
let favicon_url = favicon_url_from_page_source(&domain, &client)
|
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()
|
[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;
|
let response = client.get_async(url).await;
|
||||||
match response {
|
match response {
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
|
@ -234,7 +235,7 @@ async fn favicon_url_from_page_source(domain: &str, client: &HttpClient) -> Opti
|
||||||
if !icon_url.starts_with("https://") {
|
if !icon_url.starts_with("https://") {
|
||||||
format!("https://{}{}", domain, icon_url)
|
format!("https://{}{}", domain, icon_url)
|
||||||
} else {
|
} else {
|
||||||
icon_url.into()
|
icon_url
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
Err(_err) => None,
|
Err(_err) => None,
|
||||||
|
|
@ -257,7 +258,7 @@ fn parse_favicon(html: &str) -> Option<String> {
|
||||||
if let Some(idx) = idx {
|
if let Some(idx) = idx {
|
||||||
let start = idx + 6;
|
let start = idx + 6;
|
||||||
let html = &html[start..];
|
let html = &html[start..];
|
||||||
let end = html.find("\"");
|
let end = html.find('"');
|
||||||
|
|
||||||
if let Some(end) = end {
|
if let Some(end) = end {
|
||||||
let icon_uri = &html[..end];
|
let icon_uri = &html[..end];
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ impl<O: futures::Sink<Response> + Unpin> Service<O> {
|
||||||
service_tx.clone(),
|
service_tx.clone(),
|
||||||
plugins::help::CONFIG,
|
plugins::help::CONFIG,
|
||||||
Some(Regex::new(plugins::help::REGEX.as_ref()).expect("failed to compile help regex")),
|
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);
|
let f1 = request_handler(input, service_tx);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue