Function peek [src]

Look ahead at the next n codepoints without advancing the iterator. If fewer than n codepoints are available, then return the remainder of the string.

Prototype

pub fn peek(it: *Utf8Iterator, n: usize) []const u8

Parameters

it: *Utf8Iteratorn: usize

Source

pub fn peek(it: *Utf8Iterator, n: usize) []const u8 { const original_i = it.i; defer it.i = original_i; var end_ix = original_i; var found: usize = 0; while (found < n) : (found += 1) { const next_codepoint = it.nextCodepointSlice() orelse return it.bytes[original_i..]; end_ix += next_codepoint.len; } return it.bytes[original_i..end_ix]; }