From b34de07fe1d7392e10793c9c667fa7d47b6ddad1 Mon Sep 17 00:00:00 2001 From: Joscha Date: Sun, 22 Jan 2023 22:33:37 +0100 Subject: [PATCH] Compact function signatures --- src/bot/instance.rs | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/bot/instance.rs b/src/bot/instance.rs index ced41b0..08fe6ca 100644 --- a/src/bot/instance.rs +++ b/src/bot/instance.rs @@ -239,13 +239,11 @@ impl Instance { let _ = self.request_tx.send(Request::Stop); } - async fn run( + async fn run( config: InstanceConfig, on_event: F, mut request_rx: mpsc::UnboundedReceiver, - ) where - F: Fn(Event), - { + ) { loop { debug!("{}: Connecting...", config.name); @@ -310,14 +308,11 @@ impl Instance { } } - async fn run_once( + async fn run_once( config: &InstanceConfig, on_event: &F, request_rx: &mut mpsc::UnboundedReceiver, - ) -> Result<(), RunError> - where - F: Fn(Event), - { + ) -> Result<(), RunError> { let (mut conn, cookies) = Conn::connect( &config.server.domain, &config.room, @@ -338,14 +333,11 @@ impl Instance { } } - async fn receive( + async fn receive( config: &InstanceConfig, conn: &mut Conn, on_event: &F, - ) -> Result<(), RunError> - where - F: Fn(Event), - { + ) -> Result<(), RunError> { loop { let packet = conn.recv().await.map_err(RunError::Conn)?; let snapshot = Snapshot {