From 6fc7e7d80403d08d2705aec40fe8104d67755972 Mon Sep 17 00:00:00 2001 From: Temirkhan Myrzamadi Date: Sat, 6 Mar 2021 03:07:35 +0600 Subject: [PATCH] Adjust with the latest teloxide --- rustfmt.toml | 2 +- src/lib.rs | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/rustfmt.toml b/rustfmt.toml index 1907f64f..aba42ed2 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -2,6 +2,6 @@ format_code_in_doc_comments = true wrap_comments = true format_strings = true max_width = 80 -merge_imports = true +imports_granularity = "Crate" use_small_heuristics = "Max" use_field_init_shorthand = true diff --git a/src/lib.rs b/src/lib.rs index 5744c436..f636d6fb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -77,6 +77,13 @@ pub fn teloxide(attr: TokenStream, item: TokenStream) -> TokenStream { type>" ), }; + let requester_param_type = match params + .get(1) + .expect("A requester parameter must be specified") + { + FnArg::Typed(typed) => typed.ty.clone(), + _ => unreachable!(), + }; let aux_param_type = match params.get(2) { Some(data_param_type) => match *data_param_type { FnArg::Typed(typed) => typed.ty.clone(), @@ -101,8 +108,9 @@ pub fn teloxide(attr: TokenStream, item: TokenStream) -> TokenStream { type Aux = #aux_param_type; type Dialogue = <#fn_return_type as teloxide::dispatching::dialogue::SubtransitionOutputType>::Output; type Error = <#fn_return_type as teloxide::dispatching::dialogue::SubtransitionOutputType>::Error; + type Requester = <#requester_param_type as teloxide::dispatching::UpdateWithCxRequesterType>::Requester; - fn react(self, cx: teloxide::dispatching::dialogue::TransitionIn, aux: #aux_param_type) + fn react(self, cx: teloxide::dispatching::dialogue::TransitionIn, aux: #aux_param_type) -> futures::future::BoxFuture<'static, #fn_return_type> { #item futures::future::FutureExt::boxed(#call_fn) @@ -152,8 +160,11 @@ pub fn derive_transition(item: TokenStream) -> TokenStream { "impl teloxide::dispatching::dialogue::Transition for {1} {{type Aux \ = <{0} as teloxide::dispatching::dialogue::Subtransition>::Aux;type \ Error = <{0} as \ - teloxide::dispatching::dialogue::Subtransition>::Error;fn \ - react(self, cx: teloxide::dispatching::dialogue::TransitionIn, aux: \ + teloxide::dispatching::dialogue::Subtransition>::Error;type \ + Requester = <{0} as \ + teloxide::dispatching::dialogue::Subtransition>::Requester;fn \ + react(self, cx: \ + teloxide::dispatching::dialogue::TransitionIn, aux: \ Self::Aux) -> futures::future::BoxFuture<'static, \ teloxide::dispatching::dialogue::TransitionOut> \ {{ futures::future::FutureExt::boxed(async move {{ match self {{",