use mlua::{Function, Lua, RegistryKey, Value}; #[derive(Debug)] pub struct OwnedFunction { key: RegistryKey, } impl OwnedFunction { pub fn new<'lua>(value: Value<'lua>, lua: &'lua Lua) -> Self { let key = lua.create_registry_value(value).unwrap(); Self { key } } pub fn get<'lua>(&self, lua: &'lua Lua) -> Function<'lua> { lua.registry_value(&self.key).unwrap() } }