From 9aafbe8d952d6e31fa7273572f00ec79d9d15554 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Sun, 15 Oct 2023 09:07:21 +0100 Subject: refactor(nix-compat/derivation): make write_environment more generic We don't actually care if it's a BTreeMap of strings, bstrings or any of that sort. The only thing we want to be able to do is get a reference to the bytes from the keys and values. Change-Id: I21b85811a9ea47fe06afa3108836ef9295e5d89b Reviewed-on: https://cl.tvl.fyi/c/depot/+/9737 Tested-by: BuildkiteCI Reviewed-by: edef --- tvix/nix-compat/src/derivation/write.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'tvix/nix-compat/src') diff --git a/tvix/nix-compat/src/derivation/write.rs b/tvix/nix-compat/src/derivation/write.rs index 5e1aefa16f..01e533ced8 100644 --- a/tvix/nix-compat/src/derivation/write.rs +++ b/tvix/nix-compat/src/derivation/write.rs @@ -174,13 +174,15 @@ pub fn write_arguments(writer: &mut impl Write, arguments: &[String]) -> Result< Ok(()) } -pub fn write_enviroment( - writer: &mut impl Write, - environment: &BTreeMap, -) -> Result<(), io::Error> { +pub fn write_enviroment(writer: &mut impl Write, environment: E) -> Result<(), io::Error> +where + E: IntoIterator, + K: AsRef<[u8]>, + V: AsRef<[u8]>, +{ write_char(writer, BRACKET_OPEN)?; - for (i, (k, v)) in environment.iter().enumerate() { + for (i, (k, v)) in environment.into_iter().enumerate() { if i > 0 { write_char(writer, COMMA)?; } -- cgit 1.4.1