mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 14:35:36 +01:00
Simplify some code using struct-update-syntax
This commit is contained in:
parent
2a8f550b66
commit
8eda6cd853
3 changed files with 16 additions and 24 deletions
|
@ -39,20 +39,18 @@ impl ForceReply {
|
|||
Self { force_reply: True, input_field_placeholder: None, selective: false }
|
||||
}
|
||||
|
||||
pub fn input_field_placeholder<T>(mut self, val: T) -> Self
|
||||
pub fn input_field_placeholder<T>(self, val: T) -> Self
|
||||
where
|
||||
T: Into<Option<String>>,
|
||||
{
|
||||
self.input_field_placeholder = val.into();
|
||||
self
|
||||
Self { input_field_placeholder: val.into(), ..self }
|
||||
}
|
||||
|
||||
/// Sets [`selective`] to `true`.
|
||||
///
|
||||
/// [`selective`]: ForceReply::selective
|
||||
#[must_use]
|
||||
pub const fn selective(mut self) -> Self {
|
||||
self.selective = true;
|
||||
self
|
||||
pub fn selective(self) -> Self {
|
||||
Self { selective: true, ..self }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,41 +95,36 @@ impl KeyboardMarkup {
|
|||
/// Sets [`is_persistent`] to `true`.
|
||||
///
|
||||
/// [`is_persistent`]: KeyboardMarkup::is_persistent
|
||||
pub fn persistent(mut self) -> Self {
|
||||
self.is_persistent = true;
|
||||
self
|
||||
pub fn persistent(self) -> Self {
|
||||
Self { is_persistent: true, ..self }
|
||||
}
|
||||
|
||||
/// Sets [`resize_keyboard`] to `true`.
|
||||
///
|
||||
/// [`resize_keyboard`]: KeyboardMarkup::resize_keyboard
|
||||
pub fn resize_keyboard(mut self) -> Self {
|
||||
self.resize_keyboard = true;
|
||||
self
|
||||
pub fn resize_keyboard(self) -> Self {
|
||||
Self { resize_keyboard: true, ..self }
|
||||
}
|
||||
|
||||
/// Sets [`one_time_keyboard`] to `true`.
|
||||
///
|
||||
/// [`one_time_keyboard`]: KeyboardMarkup::one_time_keyboard
|
||||
pub fn one_time_keyboard(mut self) -> Self {
|
||||
self.one_time_keyboard = true;
|
||||
self
|
||||
pub fn one_time_keyboard(self) -> Self {
|
||||
Self { one_time_keyboard: true, ..self }
|
||||
}
|
||||
|
||||
// FIXME: document + remove Option from signature.
|
||||
pub fn input_field_placeholder<T>(mut self, val: T) -> Self
|
||||
pub fn input_field_placeholder<T>(self, val: T) -> Self
|
||||
where
|
||||
T: Into<Option<String>>,
|
||||
{
|
||||
self.input_field_placeholder = val.into();
|
||||
self
|
||||
Self { input_field_placeholder: val.into(), ..self }
|
||||
}
|
||||
|
||||
/// Sets [`selective`] to `true`.
|
||||
///
|
||||
/// [`selective`]: KeyboardMarkup::selective
|
||||
pub fn selective<T>(mut self) -> Self {
|
||||
self.selective = true;
|
||||
self
|
||||
pub fn selective<T>(self) -> Self {
|
||||
Self { selective: true, ..self }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,8 +48,7 @@ impl KeyboardRemove {
|
|||
///
|
||||
/// [`selective`]: KeyboardRemove::selective
|
||||
#[must_use]
|
||||
pub const fn selective(mut self) -> Self {
|
||||
self.selective = true;
|
||||
self
|
||||
pub const fn selective(self) -> Self {
|
||||
Self { selective: true, ..self }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue