From 09bd82d1df587dd724818660f8dcd96501a8663e Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Thu, 18 Jan 2024 19:48:13 -0600 Subject: [PATCH] hooks: Run hooks in the order they were defined Iterating over a `HashSet` produces items in an arbitrary order. A `BTreeSet`, on the other hand, produces items in the same order they were inserted. Thus, this structure is more appropriate, since the execution order of hooks may be important in some cases. --- src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index cfbab2c..78619c8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ mod model; mod templating; -use std::collections::HashSet; +use std::collections::BTreeSet; use std::io::{Read, Seek, Write}; use std::path::{Path, PathBuf}; use std::process::Command; @@ -149,7 +149,7 @@ fn process_instructions( ); let ctx = Context::from_serialize(&values)?; - let mut post_hooks = HashSet::new(); + let mut post_hooks = BTreeSet::new(); for i in instructions.render { let out = match tera.render(&i.template, &ctx) { Ok(o) => o,