From f1d477390cb42a6716a0515e21bc1d1783f58941 Mon Sep 17 00:00:00 2001 From: "Joshua M. Clulow" Date: Fri, 2 Jul 2021 00:54:42 +0000 Subject: [PATCH] stable order for property names in generated structs --- src/main.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 3cba35d..44a1139 100644 --- a/src/main.rs +++ b/src/main.rs @@ -345,7 +345,11 @@ enum TypeDetails { Basic, Array(TypeId), Optional(TypeId), - Object(HashMap), + /* + * Object property names are sorted lexicographically to ensure a stable + * order in the generated code. + */ + Object(BTreeMap), } #[derive(Debug)] @@ -603,7 +607,7 @@ impl TypeSpace { (None, None) => bail!("types need a name? {:?}", s), }; - let mut omap = HashMap::new(); + let mut omap = BTreeMap::new(); for (n, rb) in o.properties.iter() { let itid = self.select_box(None, &rb)?; if o.required.contains(n) {