Unable to call UserData method for Arc<T> #693
Answered
by
khvzak
FelicitusNeko
asked this question in
Q&A
|
I'm trying to call a method on a struct with trait impl UserData for SMState {
fn add_methods<M: mlua::UserDataMethods<Self>>(methods: &mut M) {
// [...]
methods.add_method("exit", |_lua, state, _: ()| {
state.send(SMEvents::Terminate).ok();
Ok(())
});
methods.add_async_function("sleep", async |_, msec: u64| {
sleep(Duration::from_millis(msec)).await;
Ok(())
});
// [...]
}
}And then running this Lua against it, with the sm.sleep(1000)
sm.exit()
Is there a way to work around this, or do I ultimately need to get rid of the |
Answered by
khvzak
Apr 13, 2026
Replies: 1 comment 1 reply
|
Lua has different syntax for calling methods. Try Which is a sugar for: |
1 reply
Answer selected by
FelicitusNeko
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Lua has different syntax for calling methods. Try
Which is a sugar for: