diff options
author | Florian Klink <flokli@flokli.de> | 2023-10-15T08·07+0100 |
---|---|---|
committer | flokli <flokli@flokli.de> | 2023-10-15T15·10+0000 |
commit | 9aafbe8d952d6e31fa7273572f00ec79d9d15554 (patch) | |
tree | ded46acf02ffc61e28273e621d2c39257cab099a /tvix/nix-compat/src/derivation/write.rs | |
parent | f337601f69af2470885712ddf9d5e7738e2e45c1 (diff) |
refactor(nix-compat/derivation): make write_environment more generic r/6815
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 <edef@edef.eu>
Diffstat (limited to 'tvix/nix-compat/src/derivation/write.rs')
-rw-r--r-- | tvix/nix-compat/src/derivation/write.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/tvix/nix-compat/src/derivation/write.rs b/tvix/nix-compat/src/derivation/write.rs index 5e1aefa16f06..01e533ced83b 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<String, BString>, -) -> Result<(), io::Error> { +pub fn write_enviroment<E, K, V>(writer: &mut impl Write, environment: E) -> Result<(), io::Error> +where + E: IntoIterator<Item = (K, V)>, + 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)?; } |