pub fn next_char_boundary(s: &str, start: usize) -> usize
Expand description
Returns the index of the next character boundary in the given string.
If the given index is already a character boundary, it is returned as is. If the given index is out of bounds, the length of the string is returned.
ยงExamples
use television_utils::strings::next_char_boundary;
let s = "Hello, World!";
assert_eq!(next_char_boundary(s, 0), 0);
assert_eq!(next_char_boundary(s, 1), 1);
assert_eq!(next_char_boundary(s, 13), 13);
assert_eq!(next_char_boundary(s, 30), 13);
let s = "๐๐!";
assert_eq!(next_char_boundary(s, 0), 0);
assert_eq!(next_char_boundary(s, 1), 4);
assert_eq!(next_char_boundary(s, 4), 4);
assert_eq!(next_char_boundary(s, 7), 8);
assert_eq!(next_char_boundary(s, 8), 8);