Skip to content

v0.0.12: macro-generated delegates

Choose a tag to compare

@ianm199 ianm199 released this 29 May 03:17
· 177 commits to main since this release

A #[lua_methods] method that returns a reference now auto-registers as a delegate, so a sub-reference accessor is just a normal Rust method:

#[lua_methods]
impl World {
    pub fn entity(&mut self, id: u32) -> &mut Entity { &mut self.entities[id as usize] }
}
// Lua: world:entity(5):set_hp(100)
  • -> &mut T becomes a mutable delegate; -> &T a read-only one (new AnyUserData::delegate_ref).
  • Accessor arguments are captured; &mut self + -> &T is a compile error with guidance.

Also folds in the crate-description and README cleanup from 0.0.11. No breaking changes.