Closed 124C41p closed 1 year ago
Unfortunately it would become a bit inconsistent having Map(HashMap<MapKey, Value>)
but different variants for each list type. I think that this would make the API a lot less ergonomic in a lot of cases as well - if you want to do some processing for every Value
instance you have to handle every different list type.
The enum variants of
Value
allow constructing certain objects which do not correspond to valid Protobuf data like Lists of Lists or Lists of mixed primitive types:Have you thought about replacing the
Value::List
variant by various specific variants likeValue::I32List(Vec<i32>)
,Value::MessageList(Vec<DynamicMessage>)
, etc.?On the one hand, it is always a good idea to remove invalid state. But more importantly, this change should also improve performance, as it is faster to convert between (say)
Vec<i32>
andValue
if there is aValue::I32List
variant, since I don't have to iterate over the vec and map each of its items.