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

Function char_count_or_boundary

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

Source from the content-addressed store, hash-verified

93/// the `n`-th codepoint boundary. Otherwise returns the total codepoint count.
94#[inline]
95pub(crate) fn char_count_or_boundary(string: &str, n: usize) -> StringCharLen {
96 let mut count = 0;
97 for (byte_idx, _) in string.char_indices() {
98 if count == n {
99 return StringCharLen::ByteOffset(byte_idx);
100 }
101 count += 1;
102 }
103 StringCharLen::CharCount(count)
104}
105
106/// Result of [`char_count_or_boundary`].
107pub(crate) enum StringCharLen {

Callers 4

lpad_scalar_unicodeFunction · 0.85
lpad_implFunction · 0.85
rpad_scalar_unicodeFunction · 0.85
rpad_implFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…