Skip to content

Calling methods on userdata? #173

Closed
Closed
@jugglerchris

Description

@jugglerchris

I realise it's not a great time to be asking a question give #172...

Is there a way to call a method on a UserData (or indeed a Table, or general Value) from Rust?

My use case is that I want to wrap several Rust types as UserData, which all implement the same trait. In some places I want to be able to pass any of the concrete types from Lua to a Rust function, which only cares that it implements the trait.

In my home-grown bindings I implemented this by adding as_<TRAIT> methods I can call without knowing the type, which returned something like an Rc<RefCell<dyn TRAIT>> which I could then use.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions