Skip to content

Macros for easier userdata #14

Open
@tomaka

Description

@tomaka

Something like would be great:

#[lua-userdata]
struct Foo {
    value: int,
}

#[lua-userdata]
impl Foo {
    pub fn get_value(&self) -> int {
        self.value
    }
}

lua.set("foo", Foo{ value: 5 });   // automatically fills the metatable
lua.execute("return foo:get_value()");  // would return 5

There are probably technical limitations, limiting this syntax extension to a single impl block, but maybe there's a trick that I didn't think about.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions