IterNext: pops list head; raises StopIteration when empty. */
(recv_h: u32)
| 198 | |
| 199 | /* IterNext: pops list head; raises StopIteration when empty. */ |
| 200 | fn dispatch_iter_next(recv_h: u32) -> Result<Val, VmErr> { |
| 201 | with_recv("edge_op iter_next: invalid receiver handle", recv_h, |vm, recv| { |
| 202 | if let HeapObj::List(rc) = vm.heap.get(recv) { |
| 203 | let mut v = rc.borrow_mut(); |
| 204 | if v.is_empty() { |
| 205 | return Err(VmErr::Raised(s!("StopIteration"))); |
| 206 | } |
| 207 | Ok(v.remove(0)) |
| 208 | } else { |
| 209 | Err(VmErr::TypeMsg(s!("iter_next expects a List iterator (produced by Op::Iter), got '", str vm.type_name(recv), "'"))) |
| 210 | } |
| 211 | }) |
| 212 | } |
| 213 | |
| 214 | fn dispatch_new_dict() -> Result<Val, VmErr> { |
| 215 | in_vm("edge_op new_dict called outside run()", |vm| vm.heap.alloc(HeapObj::Dict(Rc::new(RefCell::new(DictMap::new()))))) |
no test coverage detected