From 08c25212aeaebc315076a6ef558ecdfb1f33aba9 Mon Sep 17 00:00:00 2001 From: MedzikUser Date: Sun, 3 Apr 2022 21:11:11 +0200 Subject: [PATCH] fix clippy --- src/api/client.rs | 2 +- src/api/delete_image.rs | 2 +- src/api/get_image.rs | 2 +- src/api/mod.rs | 7 ++----- src/api/rate_limit.rs | 2 +- src/api/upload_image.rs | 6 +++--- src/cli/clipboard.rs | 6 ++++-- src/cli/mod.rs | 5 ++++- src/main.rs | 15 ++++++++------- 9 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/api/client.rs b/src/api/client.rs index 8a8eb70..23534ac 100644 --- a/src/api/client.rs +++ b/src/api/client.rs @@ -43,7 +43,7 @@ impl ImgurClient { format!("{path} is not url or file path"), ); - Err(anyhow::Error::from(err))? + return Err(err.into()); } upload_image(self, image).await diff --git a/src/api/delete_image.rs b/src/api/delete_image.rs index f5bba00..d207cc1 100644 --- a/src/api/delete_image.rs +++ b/src/api/delete_image.rs @@ -28,7 +28,7 @@ pub async fn delete_image(client: &ImgurClient, delete_hash: String) -> Result<( format!("server returned non-successful status code = {status}, body = {body}"), ); - Err(err)? + return Err(err.into()); } Ok(()) diff --git a/src/api/get_image.rs b/src/api/get_image.rs index 6d13ecd..542a91d 100644 --- a/src/api/get_image.rs +++ b/src/api/get_image.rs @@ -22,7 +22,7 @@ pub async fn get_image(client: &ImgurClient, image: String) -> Result Result { format!("server returned non-successful status code = {status}, body = {body}"), ); - Err(err)? + Err(err.into()) } else { let content = res.json::().await?; Ok(content) diff --git a/src/api/upload_image.rs b/src/api/upload_image.rs index 4ff1dae..b9d8281 100644 --- a/src/api/upload_image.rs +++ b/src/api/upload_image.rs @@ -5,7 +5,7 @@ use reqwest::Method; use super::{client::api_url, send_api_request, ImageInfo, ImgurClient}; -pub async fn upload_image(c: &ImgurClient, image: String) -> Result { +pub async fn upload_image(client: &ImgurClient, image: String) -> Result { // create http form (hashmap) let mut form = HashMap::new(); // insert image to form @@ -15,7 +15,7 @@ pub async fn upload_image(c: &ImgurClient, image: String) -> Result Result