MCPcopy Create free account
hub / github.com/apache/datafusion / byte_offset_of_char

Function byte_offset_of_char

datafusion/functions/src/unicode/common.rs:85–90  ·  view source on GitHub ↗
(string: &str, n: usize)

Source from the content-addressed store, hash-verified

83/// or `string.len()` if the string has fewer than `n` codepoints.
84#[inline]
85pub(crate) fn byte_offset_of_char(string: &str, n: usize) -> usize {
86 string
87 .char_indices()
88 .nth(n)
89 .map_or(string.len(), |(i, _)| i)
90}
91
92/// If `string` has more than `n` codepoints, returns the byte offset of
93/// the `n`-th codepoint boundary. Otherwise returns the total codepoint count.

Callers 1

left_right_byte_lengthFunction · 0.85

Calls 2

nthMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…