From ca5dddab54fa4930b5a6788c09c3480cc8ac0df0 Mon Sep 17 00:00:00 2001 From: Akshett Rai Jindal Date: Sat, 24 Aug 2024 13:10:05 +0530 Subject: [PATCH] Remove unecessary serde defaults and remove params from bool setters --- crates/teloxide-core/src/types/chat_shared.rs | 3 --- .../src/types/keyboard_button_request_chat.rs | 12 ++++++------ .../src/types/keyboard_button_request_users.rs | 12 ++++++------ crates/teloxide-core/src/types/shared_user.rs | 4 ---- 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/crates/teloxide-core/src/types/chat_shared.rs b/crates/teloxide-core/src/types/chat_shared.rs index 3eeace53..4616190a 100644 --- a/crates/teloxide-core/src/types/chat_shared.rs +++ b/crates/teloxide-core/src/types/chat_shared.rs @@ -15,14 +15,11 @@ pub struct ChatShared { pub chat_id: ChatId, /// Title of the chat, if it was requested. - #[serde(default)] pub title: Option, /// Username of the chat, if it was requested. - #[serde(default)] pub username: Option, /// Available sizes of the chat photo, if it was requested. - #[serde(default)] pub photo: Option>, } diff --git a/crates/teloxide-core/src/types/keyboard_button_request_chat.rs b/crates/teloxide-core/src/types/keyboard_button_request_chat.rs index b1df9448..47f9c4a3 100644 --- a/crates/teloxide-core/src/types/keyboard_button_request_chat.rs +++ b/crates/teloxide-core/src/types/keyboard_button_request_chat.rs @@ -130,22 +130,22 @@ impl KeyboardButtonRequestChat { /// Setter for `request_title` field. #[must_use] - pub fn request_title(mut self, value: bool) -> Self { - self.request_title = value; + pub fn request_title(mut self) -> Self { + self.request_title = true; self } /// Setter for `request_username` field. #[must_use] - pub fn request_username(mut self, value: bool) -> Self { - self.request_username = value; + pub fn request_username(mut self) -> Self { + self.request_username = true; self } /// Setter for `request_photo` field. #[must_use] - pub fn request_photo(mut self, value: bool) -> Self { - self.request_photo = value; + pub fn request_photo(mut self) -> Self { + self.request_photo = true; self } } diff --git a/crates/teloxide-core/src/types/keyboard_button_request_users.rs b/crates/teloxide-core/src/types/keyboard_button_request_users.rs index ea14101a..ffad3e1f 100644 --- a/crates/teloxide-core/src/types/keyboard_button_request_users.rs +++ b/crates/teloxide-core/src/types/keyboard_button_request_users.rs @@ -83,22 +83,22 @@ impl KeyboardButtonRequestUsers { /// Setter for `request_name` field #[must_use] - pub fn request_name(mut self, value: bool) -> Self { - self.request_name = Some(value); + pub fn request_name(mut self) -> Self { + self.request_name = Some(true); self } /// Setter for `request_username` field #[must_use] - pub fn request_username(mut self, value: bool) -> Self { - self.request_username = Some(value); + pub fn request_username(mut self) -> Self { + self.request_username = Some(true); self } /// Setter for `request_photo` field #[must_use] - pub fn request_photo(mut self, value: bool) -> Self { - self.request_photo = Some(value); + pub fn request_photo(mut self) -> Self { + self.request_photo = Some(true); self } } diff --git a/crates/teloxide-core/src/types/shared_user.rs b/crates/teloxide-core/src/types/shared_user.rs index ad4028bf..bca2dcb9 100644 --- a/crates/teloxide-core/src/types/shared_user.rs +++ b/crates/teloxide-core/src/types/shared_user.rs @@ -12,18 +12,14 @@ pub struct SharedUser { pub user_id: UserId, /// First name of the user, if it was requested by the bot - #[serde(default)] pub first_name: Option, /// Last name of the user, if it was requested by the bot - #[serde(default)] pub last_name: Option, /// Username of the user, if it was requested by the bot - #[serde(default)] pub username: Option, /// Available sizes of the chat photo, if it was requested - #[serde(default)] pub photo: Option>, }