From 05e32336faa7cd3bd824fb4c62647fbf484ee55e Mon Sep 17 00:00:00 2001 From: Temirkhan Myrzamadi Date: Sun, 2 Aug 2020 13:08:43 +0600 Subject: [PATCH] Add requests::respond --- README.md | 2 +- examples/dices_bot/src/main.rs | 2 +- src/prelude.rs | 2 +- src/requests/mod.rs | 5 +++++ 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5a30bab9..427b78d3 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ async fn main() { teloxide::repl(bot, |message| async move { message.answer_dice().send().await?; - ResponseResult::<()>::Ok(()) + respond(()) }) .await; } diff --git a/examples/dices_bot/src/main.rs b/examples/dices_bot/src/main.rs index ea7f4424..0f5e46bd 100644 --- a/examples/dices_bot/src/main.rs +++ b/examples/dices_bot/src/main.rs @@ -15,7 +15,7 @@ async fn run() { teloxide::repl(bot, |message| async move { message.answer_dice().send().await?; - ResponseResult::<()>::Ok(()) + respond(()) }) .await; } diff --git a/src/prelude.rs b/src/prelude.rs index 3b2032d9..a7ce757e 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -9,7 +9,7 @@ pub use crate::{ Dispatcher, DispatcherHandlerRx, DispatcherHandlerRxExt, UpdateWithCx, }, error_handlers::{LoggingErrorHandler, OnError}, - requests::{Request, ResponseResult}, + requests::{respond, Request, ResponseResult}, types::{Message, Update}, Bot, RequestError, }; diff --git a/src/requests/mod.rs b/src/requests/mod.rs index 09f2af6c..bb104ddf 100644 --- a/src/requests/mod.rs +++ b/src/requests/mod.rs @@ -9,6 +9,11 @@ pub use all::*; /// A type that is returned after making a request to Telegram. pub type ResponseResult = Result; +/// A shortcut for `ResponseResult::Ok(val)`. +pub fn respond(val: T) -> ResponseResult { + ResponseResult::Ok(val) +} + /// Designates an API request. #[async_trait::async_trait] pub trait Request {