From 3c7b51404804f40c36b7be78ace0b9a3c0b549ec Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Tue, 26 Apr 2022 14:27:58 -0700 Subject: [PATCH] Use generic parameter instead of boxing to allow mutable handlers --- src/imp.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/imp.rs b/src/imp.rs index 98189d5..b0222f8 100644 --- a/src/imp.rs +++ b/src/imp.rs @@ -47,7 +47,7 @@ impl Behaviour { /// Trait to be used by implementors of imp bots to supply their custom event handling /// the handle function is called after the default imp automatic event handling has run on each new event pub trait EventHandler { - fn handle(&self, cwtch: &dyn CwtchLib, profile: Option<&Profile>, event: CwtchEvent); + fn handle(&mut self, cwtch: &dyn CwtchLib, profile: Option<&Profile>, event: CwtchEvent); } /// Cwtch bot @@ -74,7 +74,7 @@ impl Imp { } /// The main event loop handler for the bot, supply your own customer handler to handle events after the imp's automatic handling has processed the event - pub fn event_loop(&mut self, handler: Box) { + pub fn event_loop(&mut self, handler: &mut T) where T : EventHandler { let mut initialized: bool = false; loop {