From f100bdc7edfa20210f645cc83cc08704e4f13ddf Mon Sep 17 00:00:00 2001 From: Waffle Date: Tue, 3 Sep 2019 20:23:52 +0300 Subject: [PATCH] Pin `RequestFuture` --- src/core/requests/get_me.rs | 2 +- src/core/requests/mod.rs | 9 ++++++++- src/core/requests/send_message.rs | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/core/requests/get_me.rs b/src/core/requests/get_me.rs index 5f5a14fe..7c9c4c3c 100644 --- a/src/core/requests/get_me.rs +++ b/src/core/requests/get_me.rs @@ -11,7 +11,7 @@ impl Request for GetMe { type ReturnValue = User; fn send(self) -> RequestFuture> { - Box::new(async move { + Box::pin(async move { network::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 797ea3b8..dd0ba59e 100644 --- a/src/core/requests/mod.rs +++ b/src/core/requests/mod.rs @@ -1,4 +1,5 @@ use std::future::Future; +use std::pin::Pin; use reqwest::r#async::Client; use reqwest::StatusCode; @@ -42,7 +43,9 @@ pub trait Request { fn send(self) -> RequestFuture>; } -pub type RequestFuture = Box>; +pub type RequestFuture = Pin + Send>>; + + // todo: better name? #[derive(Debug)] @@ -65,3 +68,7 @@ pub enum ChatId { pub mod get_me; pub mod send_message; + +fn a() { + use futures; +} \ No newline at end of file diff --git a/src/core/requests/send_message.rs b/src/core/requests/send_message.rs index e767d32a..6244cce7 100644 --- a/src/core/requests/send_message.rs +++ b/src/core/requests/send_message.rs @@ -25,7 +25,7 @@ impl Request for SendMessage { type ReturnValue = Message; fn send(self) -> RequestFuture> { - Box::new(async move { + Box::pin(async move { let params = FormBuilder::new() .add("chat_id", &self.chat_id) .add("text", &self.text)