git.delta.rocks / jrsonnet / refs/commits / 7b01ecbd8fbc

difftreelog

source

crates/jrsonnet-evaluator/src/stdlib/mod.rs564 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(str: IStr, vals: Val) -> Result<String> {13	State::push(14		CallLocation::native(),15		|| format!("std.format of {str}"),16		|| {17			Ok(match vals {18				Val::Arr(vals) => format_arr(&str, &vals.evaluated()?)?,19				Val::Obj(obj) => format_obj(&str, &obj)?,20				o => format_arr(&str, &[o])?,21			})22		},23	)24}