Browse Source

lang: Replace HashMap by BTreeMap for crate modules storage (#730)

aankor 4 years ago
parent
commit
11d40a23bb
1 changed files with 4 additions and 4 deletions
  1. 4 4
      lang/syn/src/parser/context.rs

+ 4 - 4
lang/syn/src/parser/context.rs

@@ -1,4 +1,4 @@
-use std::collections::HashMap;
+use std::collections::BTreeMap;
 use std::path::{Path, PathBuf};
 
 use syn::parse::{Error as ParseError, Result as ParseResult};
@@ -7,7 +7,7 @@ use syn::parse::{Error as ParseError, Result as ParseResult};
 ///
 /// Keeps track of modules defined within a crate.
 pub struct CrateContext {
-    modules: HashMap<String, ParsedModule>,
+    modules: BTreeMap<String, ParsedModule>,
 }
 
 impl CrateContext {
@@ -59,8 +59,8 @@ struct ParsedModule {
 }
 
 impl ParsedModule {
-    fn parse_recursive(root: &Path) -> Result<HashMap<String, ParsedModule>, anyhow::Error> {
-        let mut modules = HashMap::new();
+    fn parse_recursive(root: &Path) -> Result<BTreeMap<String, ParsedModule>, anyhow::Error> {
+        let mut modules = BTreeMap::new();
 
         let root_content = std::fs::read_to_string(root)?;
         let root_file = syn::parse_file(&root_content)?;