ByteIndex
public struct ByteIndex { /* private fields */ }A typed wrapper for a byte position within a String.
ByteIndex exists so that APIs taking string positions can refuse
raw Int64s, which removes the "is this a byte offset or a char
offset?" ambiguity at the call site. The wrapped value is a
plain UTF-8 byte offset; arithmetic is the caller's responsibility.
Representation
A single Int64 field.
Properties
public var value: Int64
public var value: Int64The wrapped byte offset.
Initializers
public init(Int64)
public init(Int64)Wraps a raw byte offset.
Methods
public func advance(by: Int64) -> ByteIndex
public func advance(by: Int64) -> ByteIndexAdvances by n bytes. Pure arithmetic — no string needed.
ImplementsEquatable
Associated Types
type Output = Bool
type Output = BoolMethods
public func equal(to: Self) -> Bool
public func equal(to: Self) -> BoolBridges Equal.equal(to:) to Equatable.isEqual(to:).
public func isEqual(to: ByteIndex) -> Bool
public func isEqual(to: ByteIndex) -> BoolReturns true if the two indices wrap the same byte offset.
public func notEqual(to: Self) -> Bool
public func notEqual(to: Self) -> BoolDefault !=: delegates to == so there's a single source of truth.
ImplementsComparable
Associated Types
type Output = Bool
type Output = BoolMethods
public func compare(ByteIndex) -> Ordering
public func compare(ByteIndex) -> OrderingCompares two byte indices by their wrapped offsets.
public func greaterThan(Self) -> Bool
public func greaterThan(Self) -> Bool> derived from compare.
public func greaterThanOrEqual(Self) -> Bool
public func greaterThanOrEqual(Self) -> Bool>= derived from compare.
public func isAtLeast(Self) -> Bool
public func isAtLeast(Self) -> Boolstart.. lower-bound check, derived from compare.
public func isAtMost(Self) -> Bool
public func isAtMost(Self) -> Bool..=end upper-bound check, derived from compare.
public func isBelow(Self) -> Bool
public func isBelow(Self) -> Bool..<end upper-bound check, derived from compare.
public func lessThan(Self) -> Bool
public func lessThan(Self) -> Bool< derived from compare.
public func lessThanOrEqual(Self) -> Bool
public func lessThanOrEqual(Self) -> Bool<= derived from compare.
ImplementsBytesIndex
Associated Types
type BytesYield = UInt8
type BytesYield = UInt8Methods
public func readBytes(from: BytesView) -> UInt8
public func readBytes(from: BytesView) -> UInt8public func readBytesChecked(from: BytesView) -> UInt8?
public func readBytesChecked(from: BytesView) -> UInt8?public func readBytesUnchecked(from: BytesView) -> UInt8
public func readBytesUnchecked(from: BytesView) -> UInt8Defined in lang/std/text/views.ks