StringIndex

public protocol StringIndex

Protocol for typed string indices. Each index wraps a pre-resolved byte offset; the type tag determines what unit the index addresses and what the subscript returns.

Associated Types

type Yield

Methods

func read(from: StringSlice) -> Yield

ImplementsEquatable

Associated Types

type Output = Bool

Methods

public func equal(to: Self) -> Bool

Bridges Equal.equal(to:) to Equatable.isEqual(to:).

func isEqual(to: Self) -> Bool

Returns true iff self and other are considered equal. Should be reflexive, symmetric, and transitive — Hashable requires equal values to hash equal, so don't drift from those laws.

public func notEqual(to: Self) -> Bool

Default !=: delegates to == so there's a single source of truth.

ImplementsComparable

Associated Types

type Output = Bool

Methods

func compare(Self) -> Ordering

Returns the ordering of self relative to other. Must be a total order — for any a, b, c exactly one of Less, Equal, Greater holds, and the order is transitive.

public func greaterThan(Self) -> Bool

> derived from compare.

public func greaterThanOrEqual(Self) -> Bool

>= derived from compare.

public func isAtLeast(Self) -> Bool

start.. lower-bound check, derived from compare.

public func isAtMost(Self) -> Bool

..=end upper-bound check, derived from compare.

public func isBelow(Self) -> Bool

..<end upper-bound check, derived from compare.

public func lessThan(Self) -> Bool

< derived from compare.

public func lessThanOrEqual(Self) -> Bool

<= derived from compare.

Defined in lang/std/text/slice.ks