fix: explicit default for event handler
rust derives default of T: Default, even when that's not a necessary requirement This fixes that
This commit is contained in:
1 parent
06723ad63f
commit
8056138f86
1 file changed
+8
-1
@@ -351,11 +351,18 @@ type ExternalListenerCallback<'bump, T> = BumpBox<'bump, dyn FnMut(T) + 'bump>;
|
|||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(Default)]
|
|
||||||
pub struct EventHandler<'bump, T = ()> {
|
pub struct EventHandler<'bump, T = ()> {
|
||||||
pub callback: RefCell<Option<ExternalListenerCallback<'bump, T>>>,
|
pub callback: RefCell<Option<ExternalListenerCallback<'bump, T>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Default for EventHandler<'a> {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
callback: RefCell::new(None),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T> EventHandler<'_, T> {
|
impl<T> EventHandler<'_, T> {
|
||||||
/// Call this event handler with the appropriate event type
|
/// Call this event handler with the appropriate event type
|
||||||
pub fn call(&self, event: T) {
|
pub fn call(&self, event: T) {
|
||||||
|
|||||||
Reference in new issue
Block a user