Created a little declarative macro to inherit struct fields

Hi. Just wanted to share with you guys I just created a small macro to inherit struct fields from a base struct. At this point it can only inherit from one struct but it does the job.
I needed this for long long time and checked certain proc_macro crates but eventually all of them rely some way to serialize state of macro which is not really reliable. Some use filesystem to serialize state which is also a problem in certain constrained environments.

I hope someone may find it useful so save some time typing similar fields over :slight_smile:
Here are the docs you might find some other goodies as well in this crate which are mostly what i use day to day to simplify things.

Sorry for the lack of documentation I am gonna do something about it too :slight_smile:

Is there a way to make multiple structs all inherit from one base?

If I'm reaching for a macro for this it is quite likely because I've got many structs inheriting the same shared fields.

It's a very impressive macro though, you must have learned a lot about macro_rules! syntax making it!

You can add multiple child struct they all will inherit from the same base struct however there can be only one base struct working with declarative macros are quite limiting so i cant really think of any way to inherit from multiple base structs

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.