remove requires a mutable reference while the Iterator takes an immutable reference. If you just want to empty the vector I would suggest to simply call cfg.items.clear().
What you're trying to do here is called iterator invalidation error. It's not acceptable in any languages. In C++ it would silently corrupt your memory, in Java it would throws exception, and in Rust it would fails to compile.
The cfg.items.iter() methods returns an iterator over shared references of elements in the vector. To do so, it contains a shared reference of the vector itself. Due to the aliasing rule, it effectively prevents to take a unique reference(&mut) to the vector so you can't modify it during the iterator is alive.