Skip to content

Text iterators and string views

1 min read

No import is needed.

Read the usage guide for examples and common tasks. This reference lists the public declarations for this part of the library. See Reading API signatures for parameter and result notation.

span

A view of the whole string.

public fun span(): ReadOnlySpan<char>

span

A view of [start, end), clamped exactly like substring.

public fun span(start: int, end: int): ReadOnlySpan<char>

matches_span

Returns whether this value equals the supplied text view.

public fun matches_span(borrow other: ReadOnlySpan<char>): bool

view_eq

Tests equality of the supplied text ranges.

public static extern fun view_eq(
    borrow a: string,
    ao: int,
    an: int,
    borrow b: string,
    bo: int,
    bn: int
): int

view_compare

Compares the supplied text ranges in lexical order.

public static extern fun view_compare(
    borrow a: string,
    ao: int,
    an: int,
    borrow b: string,
    bo: int,
    bn: int
): int

view_hash

Returns a hash of the specified text range.

public static extern fun view_hash(borrow s: string, off: int, n: int): int

view_find

Finds the first matching text range at or after from, or returns -1.

public static extern fun view_find(
    borrow h: string,
    ho: int,
    hn: int,
    borrow nd: string,
    no: int,
    nn: int,
    from: int
): int

view_rfind

Finds the last matching text range, or returns -1.

public static extern fun view_rfind(
    borrow h: string,
    ho: int,
    hn: int,
    borrow nd: string,
    no: int,
    nn: int
): int

view_find_char

Finds character c at or after from, or returns -1.

public static extern fun view_find_char(
    borrow s: string,
    off: int,
    n: int,
    from: int,
    c: int
): int

view_rfind_char

Finds the last occurrence of character c, or returns -1.

public static extern fun view_rfind_char(borrow s: string, off: int, n: int, c: int): int

view_count_char

Counts occurrences of character c in the specified text range.

public static extern fun view_count_char(borrow s: string, off: int, n: int, c: int): int