From 07ee03b32137283eccfe9fa45abd737823c9b16b Mon Sep 17 00:00:00 2001 From: heimoshuiyu Date: Sun, 5 Jan 2025 16:40:51 +0800 Subject: [PATCH] return download state clone --- src/main.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5e26333..94ab47d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -22,7 +22,7 @@ struct DownloadState { result: Mutex>>, } -#[derive(Debug)] +#[derive(Debug, Clone)] struct DownloadData { body: Bytes, headers: reqwest::header::HeaderMap, @@ -45,10 +45,7 @@ impl Downloader { let result = state.result.lock().await; match &*result { Some(Ok(result)) => { - return Ok(DownloadData { - body: result.body.clone(), - headers: result.headers.clone(), - }) + return Ok(result.clone()); } Some(Err(e)) => return Err(e.clone()), None => {}