OxL Справочник OxL
РусскийEnglish

error range-not-iterable

error Стандарт: [§5.3]

Перебирать (`for`, `.iter()`, адаптеры) можно только диапазоны целых чисел и `char`.

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✓ проверяется в 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✓ проверяется в 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 · Версия документации 1.0.0-beta© OxwaldLink · сгенерировано из Стандарта, исходников std и руководства