You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expected: A message with a oneof can refer to a map of itself.
Observed: An opaque error message
error[E0596]: cannot borrow `value` as mutable, as it is not declared as mutable
--> src/value_wrapper.rs:11:28
|
11 | #[derive(Clone, PartialEq, prost::Oneof)]
| ^^^^^^^^^^^^ cannot borrow as mutable
|
= note: this error originates in the derive macro `prost::Oneof` (in Nightly builds, run with -Z macro-backtrace for more info)
Source
use std::collections::HashMap;#[derive(Clone,PartialEq, prost::Message)]pubstructDiskValue{#[prost(oneof = "ValueKind", tags = "1")]pubkind:Option<ValueKind>,}#[derive(Clone,PartialEq, prost::Oneof)]pubenumValueKind{#[prost(map = "string, message", tag = "1")]Map(HashMap<String,DiskValue>),}
I carefully referenced https://github.com/tokio-rs/prost/blob/master/tests/src/message_encoding.rs . This is likely PBKAC but I seem to be missing something here. I have no field named "value" and I'm not sure how to inspect this procedural macro. I use VS Code and Rust Analyzer doesn't have an option to expand the macro to show what's happening.
I'm not using a .proto. This is my source code for dependency prost = { version = "0.13" }
The text was updated successfully, but these errors were encountered:
I don't have experience with using derive prost::OneOf. If you model this in a .proto, does that work? Is the generated code any different from the example?
You can add fields of any type, except map fields and repeated fields. If you need to add a repeated field to a oneof, you can use a message containing the repeated field.
You can add fields of any type except map fields, but you cannot use the required, optional, or repeated keywords. If you need to add a repeated field to a oneof, you can use a message containing the repeated field.
It might just be a coincidence that it doesn't compile, but it does abide to the specs.
I don't have experience with using derive prost::OneOf. If you model this in a .proto, does that work? Is the generated code any different from the example?
@kvc0 Can you provide a failing example using a .proto file?
Expected: A
message
with aoneof
can refer to a map of itself.Observed: An opaque error message
Source
I carefully referenced https://github.com/tokio-rs/prost/blob/master/tests/src/message_encoding.rs . This is likely PBKAC but I seem to be missing something here. I have no field named "value" and I'm not sure how to inspect this procedural macro. I use VS Code and Rust Analyzer doesn't have an option to expand the macro to show what's happening.
I'm not using a .proto. This is my source code for dependency
prost = { version = "0.13" }
The text was updated successfully, but these errors were encountered: