Can't this use the iterator:

```rust
for (i, (k, v)) in map.iter().enumerate() {
    if i != 0 { <print comma> }
    <print element>
}
```