From fc8cf0ed674cbb495df1baff34d4b832ca5fad3c Mon Sep 17 00:00:00 2001 From: David Orchard Date: Wed, 28 Jul 2021 22:52:15 -0700 Subject: Use LinkedHashMap in place of HashMap --- src/file/format/hjson.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/file/format/hjson.rs') 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, Box> { +) -> Result, Box> { // 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)); -- cgit v1.2.3