error range-not-iterable
What it means#
a..b and a..=b are values over any ordered type: Duration, Instant, Time, floats, strings, your own @derive(Ord) types (D-3563). They can be stored, passed to functions (net.latency(10ms..300ms)), tested with x in r / r.contains(&x) and taken apart with r.lo() / r.hi(). Iterating a range, by for x in r or r.iter(), needs a successor of every value, which only integers and char have. For any other type the range cannot be iterated.
Example#
fn main() io {
for d in 1ms..5ms { // <- range-not-iterable
print("{d}")
}
}error
range-not-iterable
How to fix#
Use the range as a value, or iterate over integers:
fn main() io {
let r = 1ms..5ms
print("{3ms in r}")
for n in 1..5 {
print("{n}")
}
}