| /* |
| * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. |
| * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. |
| */ |
| |
| package kotlin.ranges |
| |
| |
| |
| // extracted from _URanges.kt to avoid bringing a lot of transitive dependencies |
| /** |
| * Returns a range from this value up to but excluding the specified [to] value. |
| * |
| * If the [to] value is less than or equal to `this` value, then the returned range is empty. |
| */ |
| public infix fun UByte.until(to: UByte): UIntRange { |
| if (to <= UByte.MIN_VALUE) return UIntRange.EMPTY |
| return this.toUInt() .. (to - 1u).toUInt() |
| } |
| |
| /** |
| * Returns a range from this value up to but excluding the specified [to] value. |
| * |
| * If the [to] value is less than or equal to `this` value, then the returned range is empty. |
| */ |
| public infix fun UInt.until(to: UInt): UIntRange { |
| if (to <= UInt.MIN_VALUE) return UIntRange.EMPTY |
| return this .. (to - 1u).toUInt() |
| } |
| |
| /** |
| * Returns a range from this value up to but excluding the specified [to] value. |
| * |
| * If the [to] value is less than or equal to `this` value, then the returned range is empty. |
| */ |
| public infix fun ULong.until(to: ULong): ULongRange { |
| if (to <= ULong.MIN_VALUE) return ULongRange.EMPTY |
| return this .. (to - 1u).toULong() |
| } |
| |
| /** |
| * Returns a range from this value up to but excluding the specified [to] value. |
| * |
| * If the [to] value is less than or equal to `this` value, then the returned range is empty. |
| */ |
| public infix fun UShort.until(to: UShort): UIntRange { |
| if (to <= UShort.MIN_VALUE) return UIntRange.EMPTY |
| return this.toUInt() .. (to - 1u).toUInt() |
| } |