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

difftreelog

source

crates/jrsonnet-evaluator/src/stdlib/mod.rs611 Bsourcehistory
1// All builtins should return results2#![allow(clippy::unnecessary_wraps)]34use format::{format_arr, format_obj};5use jrsonnet_interner::IStr;67use crate::{error::Result, function::CallLocation, State, Val};89pub mod format;10pub mod manifest;1112pub fn std_format(s: State, str: IStr, vals: Val) -> Result<String> {13	s.push(14		CallLocation::native(),15		|| format!("std.format of {str}"),16		|| {17			Ok(match vals {18				Val::Arr(vals) => format_arr(s.clone(), &str, &vals.evaluated(s.clone())?)?,19				Val::Obj(obj) => format_obj(s.clone(), &str, &obj)?,20				o => format_arr(s.clone(), &str, &[o])?,21			})22		},23	)24}