not-fl3 / nanoserde

Serialisation library with zero dependencies

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Derive stuck on enum's unit variants that are followed by empty braces or not followed by a comma

JorgeRicoVivas opened this issue · comments

When using the derive macros (SerJson, DeJson, SerBin, DeBin, SerRon, DeRon) on an enum, if the last of the variants it's an unit variant not followed by a comma, none of the macros will compile, giving an error message), this means this wouldn't compile:

#[derive(SerJson, DeJson, SerBin, DeBin, SerRon, DeRon)]
enum Message { Goodbye, Greeting }

message: not implemented: Unexpected type in enum: Type { ident: UnNamed, wraps: None, ref_type: None, as_other: None }

but this would:

#[derive(SerJson, DeJson, SerBin, DeBin, SerRon, DeRon)]
enum Message { Goodbye, Greeting, }

Although if braces are open an unit variant, every macro except SerJson will compile (Where SerJson would give an error message as message: attempt to subtract with overflow) , meaning this compiles everything but SerJson:

#[derive(SerJson, DeJson, SerBin, DeBin, SerRon, DeRon)]
enum Message { Goodbye, Greeting{} }

and this too:

#[derive(SerJson, DeJson, SerBin, DeBin, SerRon, DeRon)]
enum Message { Goodbye{}, Greeting, }

Also, thanks for this crate!

Thanks for writing this up, I will try to look into this this weekend.

Sorry for the delay, busy time of year. I'm unable to reproduce the first one (no trailing comma), I think that was addressed for #83. A new version hasn't been released for that yet, but should be soon. I'm investigating a fix for the second one.