Make sure that imports are always in the same order between runs. This

makes the output more stable for putting it into a versioning system
like git
This commit is contained in:
Fabian Stamm
2025-07-26 13:12:34 +02:00
parent 6cb51c4120
commit 369ccbe84e
6 changed files with 66 additions and 26 deletions

View File

@ -1,6 +1,6 @@
use anyhow::Result;
use log::warn;
use std::collections::{HashMap, HashSet};
use std::collections::{BTreeMap, BTreeSet};
use crate::compile::{Compile, CompileContext, FileGenerator};
use crate::ir::{BaseType, EnumDefinition, ServiceDefinition, Step, Type, TypeDefinition};
@ -46,7 +46,7 @@ impl RustCompiler {
fn add_dependencies(
&mut self,
file: &mut FileGenerator,
depends: &HashSet<BaseType>,
depends: &BTreeSet<BaseType>,
) -> Result<()> {
for dep in depends {
match dep {
@ -409,7 +409,7 @@ impl RustCompiler {
}
impl Compile for RustCompiler {
fn new(options: &HashMap<String, String>) -> anyhow::Result<Self> {
fn new(options: &BTreeMap<String, String>) -> anyhow::Result<Self> {
let crate_name = if let Some(crate_name) = options.get("rust_crate") {
crate_name.to_string()
} else {