lenscas / tealr

A wrapper around mlua to generate documentation, definition files and other helpers
69 stars 9 forks source link

support derive macro for types with non-static lifetimes #53

Open coderedart opened 2 years ago

coderedart commented 2 years ago

I have a bunch of types like Window<'open> or Ui(&mut egui::Ui) etc.. and i would like to use MluTealrDerive on them.

but i keep getting lifetime errors. i can manually write the impls ofcourse, was just wondering if it would be possible to just make the macro support for types with lifetimes.

coderedart commented 2 years ago

for some reason, i cannot implement the TypeBody for types with lifetimes. rust complains that it needs a 'static lifetime.

lenscas commented 2 years ago

If i remember correctly, the macro quickly gets complex once generics of any kind get involved, which is why I haven't done it myself. I'll gladly accept pr's that make it work though.

I'll see what I can do about the typebody needing a static lifetime. Probably just wrote a weird lifetime myself.

However, are you sure you actually need a non static in this case? Type body is only used to generate the .d.tl file and documentation and doesn't even require an instance of the type

coderedart commented 2 years ago

However, are you sure you actually need a non static in this case? Type body is only used to generate the .d.tl file and documentation and doesn't even require an instance of the type

you are right! i was able to implement TypeBody for a 'static lifetimed struct.

I will just implement the Traits manually for now.