Skip to content

Separate chunk!'s content #439

@liketoeatcheese

Description

@liketoeatcheese
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
    });
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions