summaryrefslogtreecommitdiffstats
path: root/src/file/format/hjson.rs
diff options
context:
space:
mode:
authorDavid Orchard <if_coding@fastmail.com>2021-07-28 22:52:15 -0700
committerDavid Orchard <if_coding@fastmail.com>2021-08-15 10:31:18 -0700
commitfc8cf0ed674cbb495df1baff34d4b832ca5fad3c (patch)
treea83c82ff11399ebd2da8d7ae58da31b7f295998c /src/file/format/hjson.rs
parent62c84297e5340d717d89c5c0b36ed86dd5ad9d2f (diff)
Use LinkedHashMap in place of HashMap
Diffstat (limited to 'src/file/format/hjson.rs')
-rw-r--r--src/file/format/hjson.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/file/format/hjson.rs b/src/file/format/hjson.rs
index f94b1d3..a61afef 100644
--- a/src/file/format/hjson.rs
+++ b/src/file/format/hjson.rs
@@ -1,4 +1,4 @@
-use std::collections::HashMap;
+use linked_hash_map::LinkedHashMap;
use std::error::Error;
use crate::value::{Value, ValueKind};
@@ -6,14 +6,14 @@ use crate::value::{Value, ValueKind};
pub fn parse(
uri: Option<&String>,
text: &str,
-) -> Result<HashMap<String, Value>, Box<dyn Error + Send + Sync>> {
+) -> Result<LinkedHashMap<String, Value>, Box<dyn Error + Send + Sync>> {
// Parse a JSON object value from the text
// TODO: Have a proper error fire if the root of a file is ever not a Table
let value = from_hjson_value(uri, &serde_hjson::from_str(text)?);
match value.kind {
ValueKind::Table(map) => Ok(map),
- _ => Ok(HashMap::new()),
+ _ => Ok(LinkedHashMap::new()),
}
}
@@ -30,7 +30,7 @@ fn from_hjson_value(uri: Option<&String>, value: &serde_hjson::Value) -> Value {
serde_hjson::Value::Bool(value) => Value::new(uri, ValueKind::Boolean(value)),
serde_hjson::Value::Object(ref table) => {
- let mut m = HashMap::new();
+ let mut m = LinkedHashMap::new();
for (key, value) in table {
m.insert(key.clone(), from_hjson_value(uri, value));