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

data RangeInclusive

a..=b (§5.2).

Example:

oxl✓ проверяется в CI
fn main() io {
  var sum = 0
  for i in 1..=4 {
    sum += i
  }
  print("{sum}")
}
Вывод
10
@builtin("RangeInclusive") pub(api) data RangeInclusive<T>

Сложность. O(1) to create; iteration is lazy.

С версии. 1.0.0-beta

Методы

lo() -> T
The lower bound of the range.
hi() -> T
The upper bound of the range (included).
contains(x: &T) -> bool where T: Ord
lo <= x && x <= hi for any ordered T (D-3563); the same as x in lo..=hi.
iter() -> iter<T> where T: Ord
Lazy iterator over lo..=hi (does not overflow at the maximum value).

Определено в: std/core/types.oxl:360

См. также