Skip to content

Mutable Data Borrow in Rust Function #288

Answered by khvzak
DasLixou asked this question in Q&A
Discussion options

You must be logged in to vote

You can store arbitrary data in Lua itself using the app_data container.

eg:

    let map = HashMap::<String, RegistryKey>::new();
    lua.set_app_data(map);

However for your case probably would be easier to store function inside registry with given name:

lua.set_named_registry_value(&name, callback)?;

// Call previously saved function
lua.named_registry_value::<Function>(&name)?.call(())?;

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@DasLixou
Comment options

@khvzak
Comment options

@DasLixou
Comment options

@khvzak
Comment options

Answer selected by DasLixou
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants