toffaletti / flat_map

A compact map stored as a vector of key, value pairs.
Apache License 2.0
12 stars 7 forks source link

serialize the flat_map as a classic map #8

Closed antoine-de closed 6 years ago

antoine-de commented 6 years ago

Serialize the FlatMap as a classic Map (example in json):

{ "k1": "v1", "k2": "v2" }

instead of

{"v": [["k1", "v1"],["k2", "v2"]]}

this way the FlatMap is serialized as a classic map, and not as its internal representation

Note: I think this is a breaking change so the minor version number should be updated

note2: I also changed the serde/alloc feature to just serde as alloc needs unstable features. I'm really not sure about this change, did you need alloc for specific reason ?

antoine-de commented 6 years ago

Hi, did you had time to review the change ? If something is wrong with my contribution do not hesitate to tell me.

toffaletti commented 6 years ago

I think this is a good change. I wonder if it is possible or worth it to still support deserializing the map from an array of tuples. @Pratyush you originally added serde support, would it help you to have some backward compatibility?

Pratyush commented 6 years ago

I agree that this is a good change. The only thing I'm wondering is the alloc question. I introduced that to make serialization work in a no_std + alloc environment. I believe it should still work if we remove the alloc feature from this crate (the end user library should specify it, and then it will be used throughout the dependency tree).

antoine-de commented 6 years ago

Thanks for the review, I added the import.

Sorry, I do not think about no-std enough :confused: