mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-14 11:44:04 +01:00
attempt to remove 'static lifetime in DispatcherHandlerRxExt::commands
This commit is contained in:
parent
32c2c041c9
commit
c02af81dd1
1 changed files with 18 additions and 18 deletions
|
@ -16,13 +16,14 @@ pub trait DispatcherHandlerRxExt {
|
|||
|
||||
/// Extracts only commands with their arguments from this stream of
|
||||
/// arbitrary messages.
|
||||
fn commands<C>(
|
||||
fn commands<C, N>(
|
||||
self,
|
||||
bot_name: &'static str,
|
||||
bot_name: N,
|
||||
) -> BoxStream<'static, (DispatcherHandlerCx<Message>, C, Vec<String>)>
|
||||
where
|
||||
Self: Stream<Item = DispatcherHandlerCx<Message>>,
|
||||
C: BotCommand;
|
||||
C: BotCommand,
|
||||
N: Into<String>;
|
||||
}
|
||||
|
||||
impl<T> DispatcherHandlerRxExt for T
|
||||
|
@ -40,26 +41,25 @@ where
|
|||
}))
|
||||
}
|
||||
|
||||
fn commands<C>(
|
||||
fn commands<C, N>(
|
||||
self,
|
||||
bot_name: &'static str,
|
||||
bot_name: N,
|
||||
) -> BoxStream<'static, (DispatcherHandlerCx<Message>, C, Vec<String>)>
|
||||
where
|
||||
Self: Stream<Item = DispatcherHandlerCx<Message>>,
|
||||
C: BotCommand,
|
||||
N: Into<String> + Send,
|
||||
{
|
||||
Box::pin(self.text_messages().filter_map(
|
||||
move |(cx, text)| async move {
|
||||
C::parse(&text, bot_name).map(|(command, args)| {
|
||||
(
|
||||
cx,
|
||||
command,
|
||||
args.into_iter()
|
||||
.map(ToOwned::to_owned)
|
||||
.collect::<Vec<String>>(),
|
||||
)
|
||||
})
|
||||
},
|
||||
))
|
||||
Box::pin(self.text_messages().filter_map(|(cx, text)| async move {
|
||||
C::parse(&text, &bot_name.into()).map(|(command, args)| {
|
||||
(
|
||||
cx,
|
||||
command,
|
||||
args.into_iter()
|
||||
.map(ToOwned::to_owned)
|
||||
.collect::<Vec<String>>(),
|
||||
)
|
||||
})
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue