rune
rune copied to clipboard
Expanding Any derive to provide more features automatically
The Any
derive should be expanded to provide the following glue code automatically:
Getters and setters for any fields which are pub
, and not explicitly marked as #[any(skip)]
.
Constructor glue so that the type can be constructed in Rune with syntax appropriate for the type.
For example:
#[derive(Any)]
struct Npc {
x: i64,
y: i64,
}
#[derive(Any)]
struct Point(i64, i64);
Can be constructed like this in Rune (unless any field is marked as non-public or #[any(skip)]
):
let npc = Npc { x: 10, y: 10 };
let p = Point(20, 40);
Note: this would be implementation by using a generated constructor and mapping the appropriate constructor syntax in Rune using CompileMeta to this constructor.
Checklist
- [ ] Generating getters and setters for field not marked with
#[any(skip)]
. - [ ] Generating constructors and mapping them in the Rune compiler through
CompileMeta
.- [ ] For tuple types.
- [ ] For struct types.
- [ ] For enum types (tuple and struct variants).