-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Codegen: proto3 fields shouldn't have Option<> wrappers #92
Comments
Thanks for opening this issue and sorry for the late answer. I think the best solution would be for pb-rs to have a dedicated flag so people can decide which solution best describes there files. And default to proto3 behaviour indeed. Shouldn't be too hard. If you want to give it a try please do, else I will try to implement it on my side this month. |
scalar fields should by type T instead of Option<T>: see tafia#92
scalar fields should by type T instead of Option<T>: see tafia#92
scalar fields should by type T instead of Option<T>: see tafia#92
I have a branch I've been testing for this. Question: should I'm about to rebase my branch on https://github.com/tafia/quick-protobuf/tree/fixbuild because having OUT_DIR support seems nice. |
great! |
Yay!
IMHO, the only reason to do that is to ease migration from earlier versions of quick-protobuf and/or from proto2.
|
Ah, in that case ( |
scalar fields should by type T instead of Option<T>: see tafia#92
scalar fields should by type T instead of Option<T>: see tafia#92
scalar fields should by type T instead of Option<T>: see tafia#92
scalar fields should by type T instead of Option<T>: see tafia#92
I think this can be closed now, ya? |
As you might know, proto3 drops the concepts of default values and even of a field being present or absent at all. You can see the C++ API no longer has a
has_foo
accessor. The idea is that stuff can be represented with a simple struct.I'd love for quick-protobuf to fully support this. In
tests/rust_protobuf/v3/test_basic_pb.proto
, this message:currently maps to this generated struct:
the best proto3 representation leaves out that Option:
with MessageRead and MessageWrite implementations simplified to match. A few reasons I prefer this representation:
has_*
, you're assigning a meaning that can't be represented in other languages, so you're losing portability.fwiw, rust-protobuf drops the
Option<>
as I've suggested (but doesn't haveCow
support, which is what led me to quick-rs).(I also prefer having
unknown_fields
, but that's a separate issue.)The text was updated successfully, but these errors were encountered: