1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#![allow(clippy::unnecessary_wraps)]
use format::{format_arr, format_obj};
use crate::{error::Result, function::CallLocation, State, Val};
pub mod format;
pub fn std_format(str: &str, vals: Val) -> Result<String> {
State::push(
CallLocation::native(),
|| format!("std.format of {str}"),
|| {
Ok(match vals {
Val::Arr(vals) => format_arr(str, &vals.iter().collect::<Result<Vec<_>>>()?)?,
Val::Obj(obj) => format_obj(str, &obj)?,
o => format_arr(str, &[o])?,
})
},
)
}