attempt to remove 'static lifetime in DispatcherHandlerRxExt::commands
@@ -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,17 +41,17 @@ 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)| {
+ Box::pin(self.text_messages().filter_map(|(cx, text)| async move {
+ C::parse(&text, &bot_name.into()).map(|(command, args)| {
(
cx,
command,
@@ -59,7 +60,6 @@ where
.collect::<Vec<String>>(),
)
})
- },
- ))
+ }))
}
}
