diff --git a/src/core/requests/form_builder.rs b/src/core/requests/form_builder.rs index db8c9450..ce4a3d39 100644 --- a/src/core/requests/form_builder.rs +++ b/src/core/requests/form_builder.rs @@ -32,16 +32,14 @@ impl FormBuilder { where T: Serialize, { - Self { - form: value.map_or_else( - || self.form, - |value| { - self.form.text( - name.to_owned(), - serde_json::to_string(value).expect("serde_json::to_string failed"), - ) - }, - ), + match value { + None => Self { form: self.form }, + Some(value) => Self { + form: self.form.text( + name.to_owned(), + serde_json::to_string(value).expect("serde_json::to_string failed"), + ) + } } } diff --git a/src/core/requests/get_me.rs b/src/core/requests/get_me.rs index ca391477..464c85bf 100644 --- a/src/core/requests/get_me.rs +++ b/src/core/requests/get_me.rs @@ -18,7 +18,7 @@ impl Request for GetMe { type ReturnValue = User; fn send(self) -> RequestFuture> { - Box::new(async { + Box::new(async move { request(&self.info.client, &self.info.token, "getMe", None).await }) } diff --git a/src/core/requests/mod.rs b/src/core/requests/mod.rs index 7faab8b0..1c88f1c6 100644 --- a/src/core/requests/mod.rs +++ b/src/core/requests/mod.rs @@ -22,9 +22,9 @@ pub type RequestFuture = Box>; // todo: better name? #[derive(Debug)] -pub(crate) struct RequestInfo { - pub(crate) client: Client, - pub(crate) token: String, +pub struct RequestInfo { + pub client: Client, + pub token: String, } /// Unique identifier for the target chat or username of the target channel (in diff --git a/src/core/requests/send_message.rs b/src/core/requests/send_message.rs index b0142a98..95cdb319 100644 --- a/src/core/requests/send_message.rs +++ b/src/core/requests/send_message.rs @@ -37,7 +37,7 @@ impl Request for SendMessage { fn send(self) -> RequestFuture> { - Box::new(async { + Box::new(async move { let params = FormBuilder::new() .add("chat_id", &self.chat_id) .add("text", &self.text) diff --git a/src/core/types/message_entity.rs b/src/core/types/message_entity.rs index 427233ea..0763727f 100644 --- a/src/core/types/message_entity.rs +++ b/src/core/types/message_entity.rs @@ -12,15 +12,15 @@ pub struct MessageEntity { #[derive(Deserialize, Debug, PartialEq, Hash, Eq)] #[serde(rename_all = "snake_case")] #[serde(tag = "type")] -enum MessageEntityKind { +pub enum MessageEntityKind { Mention, Hashtag, Cashtag, BotCommand, Url, Email, PhoneNumber, Bold, Italic, Code, Pre, TextLink { url: String }, TextMention { user: User } } -#[cfg(test)] -fn test() { +#[test] +fn recursive_kind() { use serde_json::from_str; assert_eq!( diff --git a/src/lib.rs b/src/lib.rs index 7a8fc3ac..4f1e44c6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,3 @@ -#![feature(async_await)] - #[macro_use] extern crate derive_more; #[macro_use]