mlua-rs / mlua

High level Lua 5.4/5.3/5.2/5.1 (including LuaJIT) and Roblox Luau bindings to Rust with async/await support
Other
1.76k stars 139 forks source link

Separate chunk!'s content #439

Open liketoeatcheese opened 3 months ago

liketoeatcheese commented 3 months ago
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
    });
}