Closed rauanmayemir closed 1 year ago
Optional fields for proto2 syntax are treated as an alias for oneof
fields with only one element. It would be possible to differentiate optional fields from oneof
fields, and use a regular option type instead (which would be more idiomatic to ocaml), and hide this feature behind a flag to be passed to the compiler.
I'm no longer an active maintainer of the project, but you could always try and create a PR. However I would strongly recommend to switch to proto3 where ever possible.
I do use proto3 and it supports optional
since 3.15 as a way to help with presence. (it's generally considered a synthetic oneof as opposed to real oneof with multiple options)
Thank you for the answer, I'll look into it when I get free time.
I think this is related to #33
Closing as #33 has been merged. I will release a new version soon
Currently, plugin generates types for optional fields as:
I wonder what is the use case for types to be set up like that and if it's not better to simplify it to something like this: