Unable to call UserData method for Arc<T> #693
-
|
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 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Lua has different syntax for calling methods. Try Which is a sugar for: |
Beta Was this translation helpful? Give feedback.
Lua has different syntax for calling methods. Try
Which is a sugar for: