Use generic parameter instead of boxing to allow mutable handlers
This commit is contained in:
parent
e64351f6b8
commit
3c7b514048
|
@ -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<dyn EventHandler>) {
|
||||
pub fn event_loop<T>(&mut self, handler: &mut T) where T : EventHandler {
|
||||
let mut initialized: bool = false;
|
||||
|
||||
loop {
|
||||
|
|
Loading…
Reference in New Issue