From 63b62ec4bb69a00ae7d3bbe87b04ea33d6d13bd3 Mon Sep 17 00:00:00 2001 From: Arnaud Gourlay Date: Sun, 2 Feb 2025 08:12:00 +0100 Subject: [PATCH] clippy nursery --- src/client.rs | 4 ++-- src/downloader.rs | 4 ++-- src/main.rs | 14 +++++++------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/client.rs b/src/client.rs index 56bb5d3..5884c4d 100644 --- a/src/client.rs +++ b/src/client.rs @@ -4,8 +4,8 @@ use reqwest::{Client, Proxy}; use std::time::Duration; pub fn make_client( - user_agent: &Option, - proxy: &Option, + user_agent: Option<&UserAgent>, + proxy: Option<&String>, redirect: bool, connection_timeout_sec: usize, accept_invalid_certs: bool, diff --git a/src/downloader.rs b/src/downloader.rs index 6d40df0..ac111f4 100644 --- a/src/downloader.rs +++ b/src/downloader.rs @@ -25,7 +25,7 @@ pub async fn download_link( token: &CancellationToken, pb_dl: &ProgressBar, pb_manager: &ProgressBarManager, - accept_header: &Option, + accept_header: Option<&String>, ) -> Result { // select between stop signal and download select! { @@ -43,7 +43,7 @@ pub async fn download( output_dir: &str, pb_dl: &ProgressBar, pb_manager: &ProgressBarManager, - accept_header: &Option, + accept_header: Option<&String>, ) -> Result { let file_link = FileLink::new(raw_link)?; let (extension, filename_without_extension) = match file_link.extension { diff --git a/src/main.rs b/src/main.rs index 1307e0a..725f28f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -56,22 +56,22 @@ async fn main_result() -> Result<(), DlmError> { // setup HTTP clients let client = make_client( - &user_agent, - &proxy, + user_agent.as_ref(), + proxy.as_ref(), true, connection_timeout_secs, accept_invalid_certs, )?; let c_ref = &client; let client_no_redirect = make_client( - &user_agent, - &proxy, + user_agent.as_ref(), + proxy.as_ref(), false, connection_timeout_secs, accept_invalid_certs, )?; let c_no_redirect_ref = &client_no_redirect; - let accept_ref = &accept; + let accept_ref = accept.as_ref(); // trim trailing slash if any let od_ref = &output_dir .strip_suffix('/') @@ -79,7 +79,7 @@ async fn main_result() -> Result<(), DlmError> { .to_string(); // setup progress bar manager - let pbm = ProgressBarManager::init(max_concurrent_downloads, nb_of_lines as u64).await; + let pbm = ProgressBarManager::init(max_concurrent_downloads, nb_of_lines).await; let pbm_ref = &pbm; // print startup info @@ -186,7 +186,7 @@ async fn main_result() -> Result<(), DlmError> { } } -async fn count_non_empty_lines(input_file: &str) -> Result { +async fn count_non_empty_lines(input_file: &str) -> Result { let file = tfs::File::open(input_file).await?; let file_reader = tokio::io::BufReader::new(file); let stream = LinesStream::new(file_reader.lines());