fn split_at_utf16_code_unit_offset(
s: &str,
offset: u32,
) -> Result<(&str, Option<char>, &str), ()>Expand description
Split the given string at the given position measured in UTF-16 code units from the start.
Err(())indicates thatoffsetif after the end of the stringOk((before, None, after))indicates thatoffsetis between Unicode code points. The two string slices are such that:before == s.to_utf16()[..offset].to_utf8()andafter == s.to_utf16()[offset..].to_utf8()Ok((before, Some(ch), after))indicates thatoffsetis “in the middle” of a single Unicode code point that would be represented in UTF-16 by a surrogate pair of two 16-bit code units.chis that code point. The two string slices are such that:before == s.to_utf16()[..offset - 1].to_utf8()andafter == s.to_utf16()[offset + 1..].to_utf8()