Materialise a mapping into (key_str, value) pairs for `**kwargs` spread. */
(&self, v: Val)
| 84 | |
| 85 | /* Materialise a mapping into (key_str, value) pairs for `**kwargs` spread. */ |
| 86 | pub(crate) fn mapping_to_kw_pairs(&self, v: Val) -> Result<Vec<(Val, Val)>, VmErr> { |
| 87 | if !v.is_heap() { |
| 88 | return Err(VmErr::Type("argument after ** must be a mapping")); |
| 89 | } |
| 90 | match self.heap.get(v) { |
| 91 | HeapObj::Dict(rc) => { |
| 92 | let entries: Vec<(Val, Val)> = rc.borrow().iter().collect(); |
| 93 | for (k, _) in &entries { |
| 94 | if !k.is_heap() || !matches!(self.heap.get(*k), HeapObj::Str(_)) { |
| 95 | return Err(VmErr::Type("keywords must be strings")); |
| 96 | } |
| 97 | } |
| 98 | Ok(entries) |
| 99 | } |
| 100 | _ => Err(VmErr::Type("argument after ** must be a mapping")), |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | /* Seed slots with `undef()` so LoadName can detect unbound names via a u64 compare. */ |
| 105 | pub(crate) fn fill_builtins(&self, names: &[String]) -> Vec<Val> { |