mirror of
https://github.com/mlua-rs/mlua
synced 2026-06-08 16:05:43 +00:00
1a9c50f228
Callbacks should not be able to capture their arguments and hold onto them, because the `&Lua` used in previous calls will not remain valid across calls. One could imagine an API where the specific `&Lua` is simply stored inside the `Scope` itself, but this is harder to do, and would (badly) encourage storing references inside Lua userdata. Ideally, the only way it should be possible to store Lua handles inside Lua itself is through usafety or the `rental` crate or other self-borrowing techniques to make references into 'static types. If at all possible this roadblock should stay, because reference types inside userdata are almost always going to lead to a a memory leak, and if you accept the risks you should just use `RegistryKey` with its manual removal.