mlua icon indicating copy to clipboard operation
mlua copied to clipboard

Separate chunk!'s content

Open liketoeatcheese opened this issue 1 year ago • 0 comments

fn main() {
    let lua = unsafe { Lua::unsafe_new() };
    let helloworld = "test";
    let _ = lua.load(chunk!{
        print($helloworld)
    });
}

Hi I'm wondering is there a way to separate chunk! content to a separate variable and pass it in? Below is wrong since chunk! will use it as a rust variable but just to describe what I mean.

fn main() {
    let lua = unsafe { Lua::unsafe_new() };
    let helloworld = "test";
    let lua_code = "print($helloworld)";
    let _ = lua.load(chunk!{
       $lua_code
    });
}

liketoeatcheese avatar Aug 17 '24 03:08 liketoeatcheese