From 8d419b19641e3dac299735d10c50243ee28c5362 Mon Sep 17 00:00:00 2001 From: EdJoPaTo Date: Tue, 10 Sep 2024 22:54:18 +0200 Subject: [PATCH] refactor: write error variable name longer while error is nicer, err prevents another line break so its sometimes preferred --- examples/reply_to_message_updates.rs | 6 ++---- src/client_reqwest.rs | 4 ++-- src/client_ureq.rs | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/examples/reply_to_message_updates.rs b/examples/reply_to_message_updates.rs index e79f55d..e7158b0 100644 --- a/examples/reply_to_message_updates.rs +++ b/examples/reply_to_message_updates.rs @@ -21,15 +21,13 @@ fn main() { let reply_parameters = ReplyParameters::builder() .message_id(message.message_id) .build(); - let send_message_params = SendMessageParams::builder() .chat_id(message.chat.id) .text("hello") .reply_parameters(reply_parameters) .build(); - - if let Err(err) = api.send_message(&send_message_params) { - println!("Failed to send message: {err:?}"); + if let Err(error) = api.send_message(&send_message_params) { + println!("Failed to send message: {error:?}"); } } update_params.offset = Some(i64::from(update.update_id) + 1); diff --git a/src/client_reqwest.rs b/src/client_reqwest.rs index d602de7..4b16f10 100644 --- a/src/client_reqwest.rs +++ b/src/client_reqwest.rs @@ -34,7 +34,7 @@ impl AsyncApi { where Params: serde::ser::Serialize + std::fmt::Debug, { - serde_json::to_string(params).map_err(|e| Error::Encode(format!("{e:?} : {params:?}"))) + serde_json::to_string(params).map_err(|err| Error::Encode(format!("{err:?} : {params:?}"))) } pub async fn decode_response(response: reqwest::Response) -> Result @@ -55,7 +55,7 @@ impl AsyncApi { } fn parse_json(body: &str) -> Result { - serde_json::from_str(body).map_err(|e| Error::Decode(format!("{e:?} : {body:?}"))) + serde_json::from_str(body).map_err(|error| Error::Decode(format!("{error:?} : {body:?}"))) } } diff --git a/src/client_ureq.rs b/src/client_ureq.rs index 6ce0b57..52259ee 100644 --- a/src/client_ureq.rs +++ b/src/client_ureq.rs @@ -31,7 +31,7 @@ impl Api { where Params: serde::ser::Serialize + std::fmt::Debug, { - serde_json::to_string(params).map_err(|e| Error::Encode(format!("{e:?} : {params:?}"))) + serde_json::to_string(params).map_err(|err| Error::Encode(format!("{err:?} : {params:?}"))) } pub fn decode_response(response: Response) -> Result @@ -41,7 +41,7 @@ impl Api { match response.into_string() { Ok(message) => serde_json::from_str(&message) .map_err(|error| Error::Decode(format!("{error:?} : {message:?}"))), - Err(e) => Err(Error::Decode(format!("Failed to decode response: {e:?}"))), + Err(err) => Err(Error::Decode(format!("Failed to decode response: {err:?}"))), } } }