diff --git a/rust/candid/src/types/internal.rs b/rust/candid/src/types/internal.rs index c678e450..5b8535b9 100644 --- a/rust/candid/src/types/internal.rs +++ b/rust/candid/src/types/internal.rs @@ -1,7 +1,7 @@ use super::CandidType; use crate::idl_hash; use std::cell::RefCell; -use std::collections::HashMap; +use std::collections::BTreeMap; use std::fmt; // This is a re-implementation of std::any::TypeId to get rid of 'static constraint. @@ -33,8 +33,8 @@ pub fn type_of(_: &T) -> TypeId { #[derive(Default)] struct TypeName { - type_name: HashMap, - name_index: HashMap, + type_name: BTreeMap, + name_index: BTreeMap, } impl TypeName { fn get(&mut self, id: &TypeId) -> String { @@ -626,9 +626,9 @@ pub fn unroll(t: &Type) -> Type { } thread_local! { - static ENV: RefCell> = RefCell::new(HashMap::new()); + static ENV: RefCell> = RefCell::new(BTreeMap::new()); // only used for TypeContainer - static ID: RefCell> = RefCell::new(HashMap::new()); + static ID: RefCell> = RefCell::new(BTreeMap::new()); static NAME: RefCell = RefCell::new(TypeName::default()); }