Simplify requests/send_message.rs a little bit

This commit is contained in:
Temirkhan Myrzamadi 2019-09-03 09:36:34 +06:00
parent 47e97ec2be
commit 7ec19d23c2

View file

@ -37,47 +37,48 @@ impl Request for SendMessage {
.text("chat_id", format!("{:?}", self.chat_id)) .text("chat_id", format!("{:?}", self.chat_id))
.text("text", self.text) .text("text", self.text)
.apply(|f| { .apply(|f| {
if let Some(parse_mode) = self.parse_mode { self.parse_mode
f.text("parse_mode", parse_mode) .map_or_else(|| f, |parse_mode| f.text("parse_mode", parse_mode))
} else {
f
}
}) })
.apply(|f| { .apply(|f| {
if let Some(disable_web_page_preview) = self.disable_web_page_preview { self.disable_web_page_preview.map_or_else(
f.text( || f,
"disable_web_page_preview", |disable_web_page_preview| {
format!("{:?}", disable_web_page_preview), f.text(
) "disable_web_page_preview",
} else { format!("{:?}", disable_web_page_preview),
f )
} },
)
}) })
.apply(|f| { .apply(|f| {
if let Some(disable_notification) = self.disable_notification { self.disable_notification.map_or_else(
f.text( || f,
"disable_notification", |disable_notification| {
format!("{:?}", disable_notification), f.text(
) "disable_notification",
} else { format!("{:?}", disable_notification),
f )
} },
)
}) })
.apply(|f| { .apply(|f| {
if let Some(reply_to_message_id) = self.reply_to_message_id { self.reply_to_message_id.map_or_else(
f.text("reply_to_message_id", format!("{:?}", reply_to_message_id)) || f,
} else { |reply_to_message_id| {
f f.text("reply_to_message_id", format!("{:?}", reply_to_message_id))
} },
)
}) })
.apply(|f| { .apply(|f| {
if let Some(reply_markup) = self.reply_markup { self.reply_markup.map_or_else(
unimplemented!(); || f,
//f.text("reply_markup", ); |reply_markup| {
f unimplemented!();
} else { //f.text("reply_markup", );
f f
} },
)
}); });
Some(params) Some(params)