alamb commented on a change in pull request #1503: URL: https://github.com/apache/arrow-rs/pull/1503#discussion_r837822214
########## File path: arrow/src/array/array_string.rs ########## @@ -78,6 +78,39 @@ impl<OffsetSize: StringOffsetSizeTrait> GenericStringArray<OffsetSize> { self.data.buffers()[1].clone() } + /// Returns the number of chars in the string at index `i`. + /// # Panic + /// If an invalid utf-8 byte is found, the function will panic. + /// However, this function does not check every byte. So you might + /// get an unexpected result if the string is in invalid utf-8 format. + /// # Performance + /// This function has `O(n)` time complexity where `n` is the string length. + /// If you can make sure that all chars in the string are in the range `U+0x0000` ~ `U+0x007F`, + /// please use the function [`value_length`](#method.value_length) which has O(1) time complexity. + pub fn num_chars(&self, i: usize) -> usize { Review comment: I think returning the length as a `usize` is a good API and is what would be expected by rust programmers 👍 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org