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

difftreelog

source

crates/jrsonnet-evaluator/src/stdlib/mod.rs530 Bsourcehistory
1// All builtins should return results2#![allow(clippy::unnecessary_wraps)]34use format::{format_arr, format_obj};56use crate::{Result, Val, function::CallLocation, in_frame};78pub mod format;910pub fn std_format(str: &str, vals: Val) -> Result<String> {11	in_frame(12		CallLocation::native(),13		|| format!("std.format of {str}"),14		|| {15			Ok(match vals {16				Val::Arr(vals) => format_arr(str, &vals.iter().collect::<Result<Vec<_>>>()?)?,17				Val::Obj(obj) => format_obj(str, &obj)?,18				o => format_arr(str, &[o])?,19			})20		},21	)22}