OxL Reference

error range-not-iterable

error Standard: [§5.3]

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#

oxl✓ checked in CI
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:

oxl✓ checked in CI
fn main() io {
  let r = 1ms..5ms
  print("{3ms in r}")
  for n in 1..5 {
    print("{n}")
  }
}

See also#

OxL 1.0.0-beta · Documentation version 1.0.0-beta© OxwaldLink · generated from the Standard, the std sources and the guides