RangeMatchable

public protocol RangeMatchable[Bound = Self]

Protocol enabling range patterns (start..=end, ..<end, start..).

Split into three primitive comparisons rather than a single "is in range" call so the compiler can lower partial ranges (e.g. ..<10) without synthesising a stand-in upper bound. The Bound parameter lets a value be matched against bounds of a different type — e.g. an Int64 against Char bounds.

Methods

func isAtLeast(Bound) -> Bool

Returns true when self >= bound. Powers start.. patterns.

func isAtMost(Bound) -> Bool

Returns true when self <= bound. Powers ..=end patterns.

func isBelow(Bound) -> Bool

Returns true when self < bound. Powers ..<end patterns.

Defined in lang/std/core/protocols.ks