LineIndex
public struct LineIndex { /* private fields */ }A typed wrapper for a line position within a string. Stores the byte offset of the line's first byte.
Properties
public var byteOffset: Int64
public var byteOffset: Int64Initializers
public init(Int64)
public init(Int64)Methods
public func advance(by: Int64, from: StringSlice) -> LineIndex
public func advance(by: Int64, from: StringSlice) -> LineIndexAdvances by n lines. Scans for line terminators (\n, \r\n,
\r) from the current byte offset. O(n) in lines advanced.
Examples
let s = "a\nb\nc";
let idx = s.lines.startIndex; // byte 0
let second = idx.advance(by: 1, from: s.asSlice());
// second.byteOffset == 2 (past "a\n")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: LineIndex) -> Bool
public func isEqual(to: LineIndex) -> Boolpublic 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(LineIndex) -> Ordering
public func compare(LineIndex) -> Orderingpublic 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.
Defined in lang/std/text/slice.ks