msgpack-rust icon indicating copy to clipboard operation
msgpack-rust copied to clipboard

Convert Value to HashMap

Open dbrgn opened this issue 7 years ago • 2 comments

Is support for Value::as_hash_map -> Option<HashMap<EqValue, Value>> planned?

Currently it's not easy to convert a Vec<(Value, Value)> to a HashMap because Value is not Eq.

dbrgn avatar Jan 16 '18 17:01 dbrgn

No, it's not possible, because Value may be f32/f64, which are not Eq.

3Hren avatar Jan 16 '18 18:01 3Hren

Yes, but a way how this could be done is by creating a "subtype" of Value that does not include f32/f64. Value::as_hash_map would then simply fail if a key is a float.

dbrgn avatar Jan 16 '18 18:01 dbrgn