From 00b2edb2a1465c39306aab7206fff4295c4d5218 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Fri, 20 Sep 2024 14:01:25 -0700 Subject: [PATCH] the "raw pointers" solution --- src/runner/instance.rs | 4 ++-- src/runner/runner.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/runner/instance.rs b/src/runner/instance.rs index 1289826..082a406 100644 --- a/src/runner/instance.rs +++ b/src/runner/instance.rs @@ -26,8 +26,8 @@ impl Instance{ // LMAO look at this function! fn dom(lua:&mlua::Lua,mut f:impl FnMut(&mut WeakDom)->mlua::Result)->mlua::Result{ - let mut dom=lua.app_data_mut::<&'static mut WeakDom>().ok_or(mlua::Error::runtime("DataModel missing"))?; - f(&mut *dom) + let dom=*lua.app_data_mut::<*mut WeakDom>().ok_or(mlua::Error::runtime("DataModel missing"))?; + f(unsafe{&mut *dom}) } fn coerce_float(value:&mlua::Value)->Option{ diff --git a/src/runner/runner.rs b/src/runner/runner.rs index fc0fbb6..7c91a0a 100644 --- a/src/runner/runner.rs +++ b/src/runner/runner.rs @@ -79,13 +79,13 @@ impl Runner{ pub fn run_script(&self,script:crate::script::Script,context:&mut Context)->Result<(),Error>{ let yoink=script.name_source(context); //this makes set_app_data shut up about the lifetime - self.lua.set_app_data::<&'static mut rbx_dom_weak::WeakDom>(unsafe{core::mem::transmute(&mut context.dom)}); + self.lua.set_app_data::<*mut rbx_dom_weak::WeakDom>(&mut context.dom); let (name,source)=yoink.map_err(Error::Script)?; self.lua.globals().set("script",super::instance::Instance::from(script)).map_err(Error::Lua)?; self.lua.load(source) .set_name(name) .exec().map_err(Error::Lua)?; - self.lua.remove_app_data::<&'static mut rbx_dom_weak::WeakDom>(); + self.lua.remove_app_data::<*mut rbx_dom_weak::WeakDom>(); Ok(()) } }