refactor(tvix/eval): vm::add_values(): be less verbose

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>
This commit is contained in:
Adam Joseph 2023-11-12 05:45:30 -08:00 committed by clbot
parent 243a4b5699
commit 91456c3520

View file

@ -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, +)?,
};