git.delta.rocks / jrsonnet / refs/commits / cf6d90fc07cc

difftreelog

source

crates/jrsonnet-evaluator/src/tla.rs743 Bsourcehistory
1use std::{collections::HashMap, hash::BuildHasher};23use jrsonnet_interner::IStr;45use crate::{6	function::{CallLocation, PreparedFuncVal, TlaArg},7	in_description_frame, Result, Val,8};910pub fn apply_tla<H: BuildHasher>(args: &HashMap<IStr, TlaArg, H>, val: Val) -> Result<Val> {11	Ok(if let Val::Func(func) = val {12		in_description_frame(13			|| "during TLA call".to_owned(),14			|| {15				let mut names = Vec::with_capacity(args.len());16				let mut values = Vec::with_capacity(args.len());17				for (name, value) in args {18					names.push(name.clone());19					values.push(value.evaluate()?);20				}21				let prepared = PreparedFuncVal::new(func, 0, &names)?;22				prepared.call(CallLocation::native(), &[], &values)23			},24		)?25	} else {26		val27	})28}