From a0db2144a5d218f913f4cb6a170f36c596aa3c89 Mon Sep 17 00:00:00 2001 From: Matt <69441971+sigaloid@users.noreply.github.com> Date: Sat, 24 Sep 2022 22:19:13 -0400 Subject: [PATCH] Formatting + clippy changes (#12) Co-authored-by: Matthew Esposito --- src/client.rs | 4 ++-- src/server.rs | 4 ++-- src/subreddit.rs | 6 +----- src/utils.rs | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/client.rs b/src/client.rs index 2f6f82d..7f009f0 100644 --- a/src/client.rs +++ b/src/client.rs @@ -27,7 +27,7 @@ async fn stream(url: &str, req: &Request) -> Result, String let https = hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_only().enable_http1().build(); // Build the hyper client from the HTTPS connector. - let client: client::Client<_, hyper::Body> = client::Client::builder().build(https); + let client: client::Client<_, Body> = client::Client::builder().build(https); let mut builder = Request::get(uri); @@ -67,7 +67,7 @@ fn request(url: String, quarantine: bool) -> Boxed, String let https = hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build(); // Construct the hyper client from the HTTPS connector. - let client: client::Client<_, hyper::Body> = client::Client::builder().build(https); + let client: client::Client<_, Body> = client::Client::builder().build(https); // Build request let builder = Request::builder() diff --git a/src/server.rs b/src/server.rs index 979dbd7..326e54f 100644 --- a/src/server.rs +++ b/src/server.rs @@ -131,7 +131,7 @@ impl Route<'_> { impl Server { pub fn new() -> Self { - Server { + Self { default_headers: HeaderMap::new(), router: Router::new(), } @@ -159,7 +159,7 @@ impl Server { let headers = default_headers.clone(); // Remove double slashes and decode encoded slashes - let mut path = req.uri().path().replace("//", "/").replace("%2F","/"); + let mut path = req.uri().path().replace("//", "/").replace("%2F", "/"); // Remove trailing slashes if path != "/" && path.ends_with('/') { diff --git a/src/subreddit.rs b/src/subreddit.rs index 75e271a..5d099ad 100644 --- a/src/subreddit.rs +++ b/src/subreddit.rs @@ -257,11 +257,7 @@ pub async fn subscriptions_filters(req: Request) -> Result, // Redirect back to subreddit // check for redirect parameter if unsubscribing/unfiltering from outside sidebar - let path = if let Some(redirect_path) = param(&format!("?{}", query), "redirect") { - format!("/{}", redirect_path) - } else { - format!("/r/{}", sub) - }; + let path = param(&format!("?{}", query), "redirect").map_or_else(|| format!("/r/{}", sub), |redirect_path| format!("/{}", redirect_path)); let mut response = redirect(path); diff --git a/src/utils.rs b/src/utils.rs index 4f46af5..977ce69 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -469,7 +469,7 @@ impl Preferences { let mut themes = vec!["system".to_string()]; for file in ThemeAssets::iter() { let chunks: Vec<&str> = file.as_ref().split(".css").collect(); - themes.push(chunks[0].to_owned()) + themes.push(chunks[0].to_owned()); } Self { available_themes: themes,