Remove async move { /* only one future*/.await }

This commit is contained in:
Waffle 2019-09-08 01:54:59 +03:00
parent b0d88d69ea
commit 94c5320ca8
3 changed files with 20 additions and 18 deletions

View file

@ -28,14 +28,14 @@ impl<'a> Request<'a> for ForwardMessage<'a> {
type ReturnValue = Message; type ReturnValue = Message;
fn send(self) -> RequestFuture<'a, ResponseResult<Self::ReturnValue>> { fn send(self) -> RequestFuture<'a, ResponseResult<Self::ReturnValue>> {
Box::pin(async move { Box::pin(
network::request_json( network::request_json(
&self.ctx.client, self.ctx.client,
&self.ctx.token, self.ctx.token,
"forwardMessage", "forwardMessage",
&self, &self,
).await )
}) )
} }
} }

View file

@ -8,22 +8,26 @@ use crate::core::types::User;
/// A simple method for testing your bot's auth token. Requires no parameters. /// A simple method for testing your bot's auth token. Requires no parameters.
/// Returns basic information about the bot in form of a [`User`] object. /// Returns basic information about the bot in form of a [`User`] object.
pub struct GetMe<'a> { pub struct GetMe<'a> {
info: RequestContext<'a>, ctx: RequestContext<'a>,
} }
impl<'a> Request<'a> for GetMe<'a> { impl<'a> Request<'a> for GetMe<'a> {
type ReturnValue = User; type ReturnValue = User;
fn send(self) -> RequestFuture<'a, ResponseResult<Self::ReturnValue>> { fn send(self) -> RequestFuture<'a, ResponseResult<Self::ReturnValue>> {
Box::pin(async move { Box::pin(
network::request_multipart(self.info.client, self.info.token, "getMe", None) network::request_multipart(
.await self.ctx.client,
}) self.ctx.token,
"getMe",
None
)
)
} }
} }
impl<'a> GetMe<'a> { impl<'a> GetMe<'a> {
pub(crate) fn new(info: RequestContext<'a>) -> Self { pub(crate) fn new(ctx: RequestContext<'a>) -> Self {
GetMe { info } GetMe { ctx }
} }
} }

View file

@ -2,7 +2,6 @@ use crate::core::requests::form_builder::FormBuilder;
use crate::core::requests::{ use crate::core::requests::{
ChatId, Request, RequestFuture, RequestContext, ResponseResult, ChatId, Request, RequestFuture, RequestContext, ResponseResult,
}; };
use crate::core::{network, types::Message, types::ParseMode};
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
@ -44,15 +43,14 @@ impl<'a> Request<'a> for SendMessage<'a> {
type ReturnValue = Message; type ReturnValue = Message;
fn send(self) -> RequestFuture<'a, ResponseResult<Self::ReturnValue>> { fn send(self) -> RequestFuture<'a, ResponseResult<Self::ReturnValue>> {
Box::pin(async move { Box::pin(
network::request_json( network::request_json(
&self.ctx.client, self.ctx.client,
&self.ctx.token, self.ctx.token,
"sendMessage", "sendMessage",
&self, &self,
) )
.await )
})
} }
} }