From 2af30c8c7faf108bfcf649a9bf2818b25e5a63f6 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Mon, 21 Oct 2024 15:43:43 +0200 Subject: [PATCH] refactor(tvix/eval): rm From<(T, Option>)> for NixString This conversion was a bit too magic, and we can just use `NixString::new_context_from` without having to worry about the distinction between an empty context or no context, as NixString::new_context_from already deals with that internally. Change-Id: I3e5d57ecfa0f7456aa6c526863e49f2523afaec3 Reviewed-on: https://cl.tvl.fyi/c/depot/+/12754 Tested-by: BuildkiteCI Reviewed-by: edef Autosubmit: flokli --- tvix/eval/src/builtins/mod.rs | 12 +----------- tvix/eval/src/value/string/mod.rs | 9 --------- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs index 47c0f85b3..0e5d1363f 100644 --- a/tvix/eval/src/builtins/mod.rs +++ b/tvix/eval/src/builtins/mod.rs @@ -1498,17 +1498,7 @@ mod pure_builtins { let mut buf: Vec = vec![]; let context = to_xml::value_to_xml(&mut buf, &value)?; - Ok(( - buf, - // FUTUREWORK: We have a distinction between an empty context, and - // no context at all. Fix this. - if !context.is_empty() { - Some(Box::new(context)) - } else { - None - }, - ) - .into()) + Ok(NixString::new_context_from(context, buf).into()) } #[builtin("trace")] diff --git a/tvix/eval/src/value/string/mod.rs b/tvix/eval/src/value/string/mod.rs index 5bcb4786b..0f41ce9dc 100644 --- a/tvix/eval/src/value/string/mod.rs +++ b/tvix/eval/src/value/string/mod.rs @@ -455,15 +455,6 @@ impl From for NixString { } } -impl From<(T, Option>)> for NixString -where - NixString: From, -{ - fn from((s, ctx): (T, Option>)) -> Self { - Self::new(NixString::from(s).as_ref(), ctx) - } -} - impl From> for NixString { fn from(s: Box) -> Self { s.into_boxed_bytes().into()