Lyricdev
GitHub

LYR-RT0016

a collection changed while it was walked

panic ยท spec 12-stdlib

A collection of std.collections was changed while a for loop or an iterator walked it. The next step of the walk panics, naming the collection's kind; collect the changes and apply them after the loop.

Program

import std.collections { Set };

fn main(): void {
    let s = Set<int>.new();
    s.insert(1);
    for (x in s) {
        s.insert(x + 10);
    }
}