Handler::func no longer requires a closure to be sync

This commit is contained in:
StNicolay 2023-06-06 16:48:09 +03:00
parent d62f18980a
commit 10601d49ad
Signed by: StNicolay
GPG Key ID: 9693D04DCD962B0D

View File

@ -12,8 +12,7 @@ type DynHanlder<T> = Box<
MainDialogue, MainDialogue,
T, T,
) -> crate::PinnedFuture<'static, crate::Result<()>> ) -> crate::PinnedFuture<'static, crate::Result<()>>
+ Send + Send,
+ Sync,
>; >;
pub struct Handler<T> { pub struct Handler<T> {
@ -31,12 +30,11 @@ impl<T> Handler<T> {
where where
H: FnOnce(Throttle<Bot>, Message, DatabaseConnection, MainDialogue, T) -> F H: FnOnce(Throttle<Bot>, Message, DatabaseConnection, MainDialogue, T) -> F
+ Send + Send
+ Sync
+ 'static, + 'static,
F: Future<Output = crate::Result<()>> + Send + 'static, F: Future<Output = crate::Result<()>> + Send + 'static,
{ {
let handler = Self { let handler = Self {
func: Some(Box::new(move |bot, msg, db, dialogue, val| { func: Some(Box::new(|bot, msg, db, dialogue, val| {
Box::pin(f(bot, msg, db, dialogue, val)) Box::pin(f(bot, msg, db, dialogue, val))
})), })),
previous: previous.into(), previous: previous.into(),