Fix a few things and format the code

This commit is contained in:
Temirkhan Myrzamadi 2019-09-03 13:04:07 +06:00
parent 47d56c7ddd
commit 23b94bab01
2 changed files with 18 additions and 7 deletions

View file

@ -9,6 +9,11 @@ where
{ {
value.map_or_else( value.map_or_else(
|| form, || form,
|value| form.text(name.to_owned(), serde_json::to_string(value).expect("Failed to serialize a value to JSON")), |value| {
form.text(
name.to_owned(),
serde_json::to_string(value).expect("serde_json::to_string failed"),
)
},
) )
} }

View file

@ -32,7 +32,7 @@ impl Request for SendMessage {
} }
fn params(self) -> Option<Form> { fn params(self) -> Option<Form> {
let params = Form::new() let params = Form::new()
.text("chat_id", format!("{}", self.chat_id)) .text("chat_id", serde_json::to_string(&self.chat_id).unwrap())
.text("text", self.text); .text("text", self.text);
let params = helpers::add_to_form_if_some(params, "parse_mode", self.parse_mode.as_ref()); let params = helpers::add_to_form_if_some(params, "parse_mode", self.parse_mode.as_ref());
let params = helpers::add_to_form_if_some( let params = helpers::add_to_form_if_some(
@ -40,10 +40,16 @@ impl Request for SendMessage {
"disable_web_page_preview", "disable_web_page_preview",
self.disable_web_page_preview.as_ref(), self.disable_web_page_preview.as_ref(),
); );
let params = let params = helpers::add_to_form_if_some(
helpers::add_to_form_if_some(params, "disable_notification", self.disable_notification.as_ref()); params,
let params = "disable_notification",
helpers::add_to_form_if_some(params, "reply_to_message_id", self.reply_to_message_id.as_ref()); self.disable_notification.as_ref(),
);
let params = helpers::add_to_form_if_some(
params,
"reply_to_message_id",
self.reply_to_message_id.as_ref(),
);
// TODO: // TODO:
// helpers::add_to_form_if_some( // helpers::add_to_form_if_some(