diff --git a/crates/kobold/src/stateful/hook.rs b/crates/kobold/src/stateful/hook.rs index 7ec5f62..66cc80f 100644 --- a/crates/kobold/src/stateful/hook.rs +++ b/crates/kobold/src/stateful/hook.rs @@ -100,7 +100,7 @@ impl Hook { F: Fn(&mut S, E) -> O + 'static, O: ShouldRender, { - let inner = &self.inner as *const Inner; + let inner = &self.inner; Bound { inner, callback } } @@ -144,12 +144,12 @@ impl Hook { } } -pub struct Bound { - inner: *const Inner, +pub struct Bound<'b, S, F> { + inner: &'b Inner, callback: F, } -impl Bound { +impl Bound<'_, S, F> { pub fn into_listener(self) -> impl Listener where S: 'static, @@ -159,6 +159,7 @@ impl Bound { { let Bound { inner, callback } = self; + let inner = inner as *const Inner; let bound = move |e| { // ⚠️ Safety: // ========== @@ -181,7 +182,7 @@ impl Bound { } } -impl Clone for Bound +impl Clone for Bound<'_, S, F> where F: Clone, { @@ -193,7 +194,7 @@ where } } -impl Copy for Bound where F: Copy {} +impl Copy for Bound<'_, S, F> where F: Copy {} struct BoundListener { bound: B, @@ -275,7 +276,7 @@ mod test { }; let mock = Bound { - inner: &inner as *const _, + inner: &inner, callback: |state: &mut i32, _: web_sys::Event| { *state += 1; },