about summary refs log tree commit diff
path: root/tvix/eval/src
diff options
context:
space:
mode:
authorAdam Joseph <adam@westernsemico.com>2023-11-12T13·45-0800
committerclbot <clbot@tvl.fyi>2023-12-12T18·00+0000
commit91456c3520a03e0f3b73224f1d80c56a5392fe32 (patch)
tree2aa845b32394d79b4d2d2eb67e48a621a9604097 /tvix/eval/src
parent243a4b569909be678e0ddfcc1c66c62ff3ddb487 (diff)
refactor(tvix/eval): vm::add_values(): be less verbose r/7206
Change-Id: Icf328649fd70bdf0fc3ba6cd7754ae29735f11f7
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10035
Autosubmit: Adam Joseph <adam@westernsemico.com>
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
Diffstat (limited to 'tvix/eval/src')
-rw-r--r--tvix/eval/src/vm/mod.rs20
1 files changed, 8 insertions, 12 deletions
diff --git a/tvix/eval/src/vm/mod.rs b/tvix/eval/src/vm/mod.rs
index 5b9aecb8d440..fd71dbacf480 100644
--- a/tvix/eval/src/vm/mod.rs
+++ b/tvix/eval/src/vm/mod.rs
@@ -1214,18 +1214,14 @@ async fn add_values(co: GenCo, a: Value, b: Value) -> Result<Value, ErrorKind> {
             }
         }
         (Value::String(s1), Value::String(s2)) => Value::String(s1.concat(&s2)),
-        (Value::String(s1), v) => Value::String(
-            match generators::request_string_coerce(&co, v, CoercionKind::Weak).await {
-                Ok(s2) => s1.concat(&s2),
-                Err(c) => return Ok(Value::Catchable(c)),
-            },
-        ),
-        (v, Value::String(s2)) => Value::String(
-            match generators::request_string_coerce(&co, v, CoercionKind::Weak).await {
-                Ok(s1) => s1.concat(&s2),
-                Err(c) => return Ok(Value::Catchable(c)),
-            },
-        ),
+        (Value::String(s1), v) => generators::request_string_coerce(&co, v, CoercionKind::Weak)
+            .await
+            .map(|s2| Value::String(s1.concat(&s2)))
+            .into(),
+        (v, Value::String(s2)) => generators::request_string_coerce(&co, v, CoercionKind::Weak)
+            .await
+            .map(|s1| Value::String(s1.concat(&s2)))
+            .into(),
         (a, b) => arithmetic_op!(&a, &b, +)?,
     };