diff options
author | David Orchard <if_coding@fastmail.com> | 2021-07-28 22:52:15 -0700 |
---|---|---|
committer | David Orchard <if_coding@fastmail.com> | 2021-08-15 10:31:18 -0700 |
commit | fc8cf0ed674cbb495df1baff34d4b832ca5fad3c (patch) | |
tree | a83c82ff11399ebd2da8d7ae58da31b7f295998c /src/value.rs | |
parent | 62c84297e5340d717d89c5c0b36ed86dd5ad9d2f (diff) |
Use LinkedHashMap in place of HashMap
Diffstat (limited to 'src/value.rs')
-rw-r--r-- | src/value.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/value.rs b/src/value.rs index 8db5fcc..e8f41c9 100644 --- a/src/value.rs +++ b/src/value.rs @@ -1,4 +1,4 @@ -use std::collections::HashMap; +use linked_hash_map::LinkedHashMap; use std::fmt; use std::fmt::Display; @@ -23,7 +23,7 @@ pub enum ValueKind { } pub type Array = Vec<Value>; -pub type Table = HashMap<String, Value>; +pub type Table = LinkedHashMap<String, Value>; impl Default for ValueKind { fn default() -> Self { @@ -73,11 +73,11 @@ impl From<bool> for ValueKind { } } -impl<T> From<HashMap<String, T>> for ValueKind +impl<T> From<LinkedHashMap<String, T>> for ValueKind where T: Into<Value>, { - fn from(values: HashMap<String, T>) -> Self { + fn from(values: LinkedHashMap<String, T>) -> Self { let t = values.into_iter().map(|(k, v)| (k, v.into())).collect(); ValueKind::Table(t) } @@ -357,7 +357,7 @@ impl Value { /// If the `Value` is a Table, returns the associated Map. // FIXME: Should this not be `try_into_*` ? - pub fn into_table(self) -> Result<HashMap<String, Value>> { + pub fn into_table(self) -> Result<LinkedHashMap<String, Value>> { match self.kind { ValueKind::Table(value) => Ok(value), |