[oden-js] Ensure callbacks have 'static lifetime
Because we smuggle them through we need to make sure they're not holding references that will go invalid- we can make no promises about how long they stay alive. Although maybe bounding to context lifetime is OK? But anyway.
This commit is contained in:
parent
14f9eb655f
commit
e36ab17235
3 changed files with 8 additions and 8 deletions
|
|
@ -3,9 +3,9 @@ use oden_js_sys as sys;
|
|||
use std::ffi::c_int;
|
||||
use std::panic::catch_unwind;
|
||||
|
||||
pub trait Callback: Fn(&ContextRef, &ValueRef, &[&ValueRef]) -> ValueResult {}
|
||||
pub trait Callback: 'static + Fn(&ContextRef, &ValueRef, &[&ValueRef]) -> ValueResult {}
|
||||
|
||||
impl<T> Callback for T where T: Fn(&ContextRef, &ValueRef, &[&ValueRef]) -> ValueResult {}
|
||||
impl<T> Callback for T where T: 'static + Fn(&ContextRef, &ValueRef, &[&ValueRef]) -> ValueResult {}
|
||||
|
||||
struct CallbackObject<T: Callback> {
|
||||
callback: T,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue