From eccf7243c466f572227914ce4f7bf2a0f408fbab Mon Sep 17 00:00:00 2001 From: Quaternions Date: Sat, 5 Oct 2024 12:09:57 -0700 Subject: [PATCH] fake out nil parent --- src/runner/instance.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/runner/instance.rs b/src/runner/instance.rs index a54f826..7a3a5af 100644 --- a/src/runner/instance.rs +++ b/src/runner/instance.rs @@ -9,11 +9,11 @@ pub fn set_globals(lua:&mlua::Lua,globals:&mlua::Table<'_>)->Result<(),mlua::Err //Instance.new instance_table.raw_set("new", - lua.create_function(|lua,(class_name,parent):(mlua::String,Instance)|{ + lua.create_function(|lua,(class_name,parent):(mlua::String,Option)|{ let class_name_str=class_name.to_str()?; + let parent=parent.ok_or(mlua::Error::runtime("Nil Parent not yet supported"))?; dom_mut(lua,|dom|{ - //TODO: Nil instances, accept optional parent:Option - //let parent_ref=parent.map_or(NIL_INSTANCES,|instance|instance.referent); + //TODO: Nil instances Ok(Instance::new(dom.insert(parent.referent,InstanceBuilder::new(class_name_str)))) }) })?