Merge pull request 'Use generic parameter instead of boxing to allow mutable handlers' (#1) from imp-fixes into main
Reviewed-on: #1
This commit is contained in:
commit
d61c4086d4
|
@ -75,7 +75,7 @@ impl BehaviourBuilder {
|
|||
/// 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
|
||||
|
@ -102,7 +102,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