Working on some form of inheritance in rust. It’s my first foray into procedural macros and so far it’s fun. The idea is quite simple: generate structs with common attributes (and eventually functions) instead writing them yourself.
The latter leads to indirection which I’m not a fan of.
Last week I squashed one bug on the order of attributes according to inheritance. In the example above attr2 was coming before attr1. A feature is nearly done to exclude the Parent from the output and only output the child. That’s useful for parents that just serve as holders for shared attributes.
The goal for v1 was to also support basic inheritance of implementations: Parent has an impl block, then that block is copied for the Child. Not sure yet if I’ll implement overrides in v1 or v2. Overrides being if Parent implements do_something() and Child does too, then the implementation of Parent is not copied into the impl block.
That’s what I’ll try to tackle in the coming weeks.
Working on some form of inheritance in rust. It’s my first foray into procedural macros and so far it’s fun. The idea is quite simple: generate structs with common attributes (and eventually functions) instead writing them yourself.
becomes
not
The latter leads to indirection which I’m not a fan of.
Last week I squashed one bug on the order of attributes according to inheritance. In the example above
attr2was coming beforeattr1. A feature is nearly done to exclude theParentfrom the output and only output the child. That’s useful for parents that just serve as holders for shared attributes.The goal for v1 was to also support basic inheritance of implementations:
Parenthas animplblock, then that block is copied for theChild. Not sure yet if I’ll implement overrides in v1 or v2. Overrides being ifParentimplementsdo_something()andChilddoes too, then the implementation ofParentis not copied into theimplblock.That’s what I’ll try to tackle in the coming weeks.