Closed ctrlcctrlv closed 2 years ago
Dictionary
keys are always strings.
The "standard" form for collection conversions in Rust seems to be .into_iter().collect()
. Presumably because it works for all map types.
It might be worth extending:
impl FromIterator<(String, Value)> for Dictionary
to:
impl<K: Into<String>, V: Into<Value>> FromIterator<(K, V)> for Dictionary
so that people can convert like this:
let dict: Dictionary = hash_map.into_iter().collect();
Yeah, that works for me. :-)
Not so sure about the definitions of
K
andV
, but given thatDate
implementsFrom<SystemTime>
(that being thestd::time::SystemTime
, and thatArray
is just aVec<T>
, I think that it's a mistake thatDictionary
cannot be converted back and forth from the standardstd::collections::HashMap
.