feat: rec attrset
This commit is contained in:
@@ -27,11 +27,28 @@ pub mod builtins {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn import<Ctx: BuiltinsContext>(ctx: &mut Ctx, path: Value) -> Result<Value> {
|
||||
pub fn import(ctx: &mut impl BuiltinsContext, path: Value) -> Result<Value> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn elem_at(list: Value, idx: Value) -> Result<Value> {
|
||||
let list = list
|
||||
.try_unwrap_list()
|
||||
.map_err(|_| Error::EvalError("expected a list but found ...".to_string()))?;
|
||||
let idx = idx
|
||||
.try_unwrap_int()
|
||||
.map_err(|_| Error::EvalError("expected a int but found ...".to_string()))?;
|
||||
list.get(idx as usize)
|
||||
.ok_or_else(|| {
|
||||
Error::EvalError(format!(
|
||||
"'builtins.elemAt' called with index {idx} on a list of size {}",
|
||||
list.len()
|
||||
))
|
||||
})
|
||||
.cloned()
|
||||
}
|
||||
|
||||
fn elem(elem: Value, list: Value) -> Result<Value> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user