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;
fn send(self) -> RequestFuture<'a, ResponseResult<Self::ReturnValue>> {
Box::pin(async move {
Box::pin(
network::request_json(
&self.ctx.client,
&self.ctx.token,
self.ctx.client,
self.ctx.token,
"forwardMessage",
&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.
/// Returns basic information about the bot in form of a [`User`] object.
pub struct GetMe<'a> {
info: RequestContext<'a>,
ctx: RequestContext<'a>,
}
impl<'a> Request<'a> for GetMe<'a> {
type ReturnValue = User;
fn send(self) -> RequestFuture<'a, ResponseResult<Self::ReturnValue>> {
Box::pin(async move {
network::request_multipart(self.info.client, self.info.token, "getMe", None)
.await
})
Box::pin(
network::request_multipart(
self.ctx.client,
self.ctx.token,
"getMe",
None
)
)
}
}
impl<'a> GetMe<'a> {
pub(crate) fn new(info: RequestContext<'a>) -> Self {
GetMe { info }
pub(crate) fn new(ctx: RequestContext<'a>) -> Self {
GetMe { ctx }
}
}

View file

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