mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-24 09:16:12 +01:00
Remove the redundant Box
in DefaultHandler
This commit is contained in:
parent
c2bc945d27
commit
e4459c408d
1 changed files with 10 additions and 10 deletions
|
@ -27,7 +27,7 @@ pub struct DispatcherBuilder<R, Err> {
|
||||||
bot: R,
|
bot: R,
|
||||||
dependencies: DependencyMap,
|
dependencies: DependencyMap,
|
||||||
handler: Arc<UpdateHandler<Err>>,
|
handler: Arc<UpdateHandler<Err>>,
|
||||||
default_handler: Arc<DefaultHandler>,
|
default_handler: DefaultHandler,
|
||||||
error_handler: Arc<dyn ErrorHandler<Err> + Send + Sync>,
|
error_handler: Arc<dyn ErrorHandler<Err> + Send + Sync>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,10 +48,10 @@ where
|
||||||
let handler = Arc::new(handler);
|
let handler = Arc::new(handler);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
default_handler: Arc::new(Box::new(move |upd| {
|
default_handler: Arc::new(move |upd| {
|
||||||
let handler = Arc::clone(&handler);
|
let handler = Arc::clone(&handler);
|
||||||
Box::pin(handler(upd))
|
Box::pin(handler(upd))
|
||||||
})),
|
}),
|
||||||
..self
|
..self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ pub struct Dispatcher<R, Err> {
|
||||||
dependencies: DependencyMap,
|
dependencies: DependencyMap,
|
||||||
|
|
||||||
handler: Arc<UpdateHandler<Err>>,
|
handler: Arc<UpdateHandler<Err>>,
|
||||||
default_handler: Arc<DefaultHandler>,
|
default_handler: DefaultHandler,
|
||||||
|
|
||||||
// Tokio TX channel parts associated with chat IDs that consume updates sequentially.
|
// Tokio TX channel parts associated with chat IDs that consume updates sequentially.
|
||||||
workers: HashMap<i64, WorkerTx>,
|
workers: HashMap<i64, WorkerTx>,
|
||||||
|
@ -121,7 +121,7 @@ type WorkerTx = tokio::sync::mpsc::Sender<Update>;
|
||||||
/// A handler that processes updates from Telegram.
|
/// A handler that processes updates from Telegram.
|
||||||
pub type UpdateHandler<Err> = dptree::Handler<'static, DependencyMap, Result<(), Err>>;
|
pub type UpdateHandler<Err> = dptree::Handler<'static, DependencyMap, Result<(), Err>>;
|
||||||
|
|
||||||
type DefaultHandler = Box<dyn Fn(Arc<Update>) -> BoxFuture<'static, ()> + Send + Sync>;
|
type DefaultHandler = Arc<dyn Fn(Arc<Update>) -> BoxFuture<'static, ()> + Send + Sync>;
|
||||||
|
|
||||||
impl<R, Err> Dispatcher<R, Err>
|
impl<R, Err> Dispatcher<R, Err>
|
||||||
where
|
where
|
||||||
|
@ -138,10 +138,10 @@ where
|
||||||
bot,
|
bot,
|
||||||
dependencies: DependencyMap::new(),
|
dependencies: DependencyMap::new(),
|
||||||
handler: Arc::new(handler),
|
handler: Arc::new(handler),
|
||||||
default_handler: Arc::new(Box::new(|upd| {
|
default_handler: Arc::new(|upd| {
|
||||||
log::warn!("Unhandled update: {:?}", upd);
|
log::warn!("Unhandled update: {:?}", upd);
|
||||||
Box::pin(async {})
|
Box::pin(async {})
|
||||||
})),
|
}),
|
||||||
error_handler: LoggingErrorHandler::new(),
|
error_handler: LoggingErrorHandler::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -307,7 +307,7 @@ const WORKER_QUEUE_SIZE: usize = 64;
|
||||||
fn spawn_worker<Err>(
|
fn spawn_worker<Err>(
|
||||||
deps: DependencyMap,
|
deps: DependencyMap,
|
||||||
handler: Arc<UpdateHandler<Err>>,
|
handler: Arc<UpdateHandler<Err>>,
|
||||||
default_handler: Arc<DefaultHandler>,
|
default_handler: DefaultHandler,
|
||||||
error_handler: Arc<dyn ErrorHandler<Err> + Send + Sync>,
|
error_handler: Arc<dyn ErrorHandler<Err> + Send + Sync>,
|
||||||
) -> WorkerTx
|
) -> WorkerTx
|
||||||
where
|
where
|
||||||
|
@ -338,7 +338,7 @@ where
|
||||||
fn spawn_default_worker<Err>(
|
fn spawn_default_worker<Err>(
|
||||||
deps: DependencyMap,
|
deps: DependencyMap,
|
||||||
handler: Arc<UpdateHandler<Err>>,
|
handler: Arc<UpdateHandler<Err>>,
|
||||||
default_handler: Arc<DefaultHandler>,
|
default_handler: DefaultHandler,
|
||||||
error_handler: Arc<dyn ErrorHandler<Err> + Send + Sync>,
|
error_handler: Arc<dyn ErrorHandler<Err> + Send + Sync>,
|
||||||
) -> WorkerTx
|
) -> WorkerTx
|
||||||
where
|
where
|
||||||
|
@ -370,7 +370,7 @@ async fn handle_update<Err>(
|
||||||
update: Update,
|
update: Update,
|
||||||
deps: Arc<DependencyMap>,
|
deps: Arc<DependencyMap>,
|
||||||
handler: Arc<UpdateHandler<Err>>,
|
handler: Arc<UpdateHandler<Err>>,
|
||||||
default_handler: Arc<DefaultHandler>,
|
default_handler: DefaultHandler,
|
||||||
error_handler: Arc<dyn ErrorHandler<Err> + Send + Sync>,
|
error_handler: Arc<dyn ErrorHandler<Err> + Send + Sync>,
|
||||||
) where
|
) where
|
||||||
Err: Send + Sync + 'static,
|
Err: Send + Sync + 'static,
|
||||||
|
|
Loading…
Add table
Reference in a new issue