replace `range` with an external iterator
auto merge of #8216 : thestinger/rust/range, r=huonw