[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
|
|
@ -270,7 +270,7 @@ impl ValueRef {
|
|||
&mut self,
|
||||
ctx: &ContextRef,
|
||||
prop: &str,
|
||||
func: impl RustFunction<F>,
|
||||
func: impl RustFunction<F> + 'static,
|
||||
) -> Result<()> {
|
||||
let vr: Value = ctx.new_fn(func)?;
|
||||
self.set_property(ctx, prop, &vr)
|
||||
|
|
@ -278,7 +278,7 @@ impl ValueRef {
|
|||
|
||||
pub fn set_dynamic_method<F>(&mut self, ctx: &ContextRef, prop: &str, func: F) -> Result<()>
|
||||
where
|
||||
F: Fn(&ContextRef, &ValueRef, &[&ValueRef]) -> Result<Value>,
|
||||
F: 'static + Fn(&ContextRef, &ValueRef, &[&ValueRef]) -> Result<Value>,
|
||||
{
|
||||
let vr: Value = ctx.new_dynamic_fn(func)?;
|
||||
self.set_property(ctx, prop, &vr)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue