Closed mkpankov closed 7 years ago
Your test always passes because the closure doesn't contain move
.
I'd even suggest using an Arc<Foo>
instead of a Foo
so that you are sure that it's not the local variable that is destroyed.
You can also have the destructor increment a static variable and check its expected value in multiple places
Don't merge this, still WIP.
Using Arc
or Rc
starts to cause SIGSEGV, investigating.
Ok, so it segfaults because for closure userdata, I don't push a TypeId
and then destructor_wrapper
does wrong stuff here:
https://github.com/tomaka/hlua/blob/master/hlua/src/userdata.rs#L24
Gonna add another destructor wrapper for closures specifically, as I don't want to require 'static
on Z
in Push for Function<Z,...
. Closure pushed to Lua must just outlive Lua, not be static.
Should be good to go now.
Thanks, looks good other than the nit.
This fixes #138 . However, see comments for newly added test.