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

Function left_right_byte_length

datafusion/functions/src/unicode/common.rs:117–129  ·  view source on GitHub ↗
(string: &str, n: i64)

Source from the content-addressed store, hash-verified

115/// Calculate the byte length of the substring of `n` chars from string `string`
116#[inline]
117fn left_right_byte_length(string: &str, n: i64) -> usize {
118 match n.cmp(&0) {
119 Ordering::Less => string
120 .char_indices()
121 .nth_back((n.unsigned_abs().min(usize::MAX as u64) - 1) as usize)
122 .map(|(index, _)| index)
123 .unwrap_or(0),
124 Ordering::Equal => 0,
125 Ordering::Greater => {
126 byte_offset_of_char(string, n.unsigned_abs().min(usize::MAX as u64) as usize)
127 }
128 }
129}
130
131/// General implementation for `left` and `right` functions
132pub(crate) fn general_left_right<F: LeftRightSlicer>(

Callers 1

sliceMethod · 0.85

Calls 4

byte_offset_of_charFunction · 0.85
cmpMethod · 0.45
mapMethod · 0.45
minMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…