Remove unecessary serde defaults and remove params from bool setters

This commit is contained in:
Akshett Rai Jindal 2024-08-24 13:10:05 +05:30
parent 31caa3ba04
commit ca5dddab54
4 changed files with 12 additions and 19 deletions

View file

@ -15,14 +15,11 @@ pub struct ChatShared {
pub chat_id: ChatId,
/// Title of the chat, if it was requested.
#[serde(default)]
pub title: Option<String>,
/// Username of the chat, if it was requested.
#[serde(default)]
pub username: Option<String>,
/// Available sizes of the chat photo, if it was requested.
#[serde(default)]
pub photo: Option<Vec<PhotoSize>>,
}

View file

@ -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
}
}

View file

@ -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
}
}

View file

@ -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<String>,
/// Last name of the user, if it was requested by the bot
#[serde(default)]
pub last_name: Option<String>,
/// Username of the user, if it was requested by the bot
#[serde(default)]
pub username: Option<String>,
/// Available sizes of the chat photo, if it was requested
#[serde(default)]
pub photo: Option<Vec<PhotoSize>>,
}