microcad_lang/eval/
tuple.rs

1// Copyright © 2025 The µcad authors <info@ucad.xyz>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4use crate::eval::*;
5
6impl Eval for TupleExpression {
7    fn eval(&self, context: &mut Context) -> EvalResult<Value> {
8        let (unnamed, named): (Vec<_>, _) = self
9            .args
10            .eval(context)?
11            .iter()
12            .map(|(id, arg)| (id.clone(), arg.value.clone()))
13            .partition(|(id, _)| id.is_none());
14
15        Ok(Value::Tuple(
16            Tuple {
17                named: named.into_iter().collect(),
18                unnamed: unnamed.into_iter().map(|(_, v)| (v.ty(), v)).collect(),
19                src_ref: self.src_ref.clone(),
20            }
21            .into(),
22        ))
23    }
24}