A label split in two
ASCII labels render. Localized labels sometimes crash the widget.
What’s going wrong
A dashboard splits a label between two cells. English examples work, but certain localized labels panic or put the wrong number of characters in the left cell.
Input is a nonnegative character count on the first line and a UTF-8 label on the second. Split after that many Unicode scalar values, or at the end if the requested count exceeds the label length. Print `left|right`. Do not lose or replace characters. An empty label is valid. Labels contain no `|` and no newline. Here “character” means a Rust `char`, not a grapheme cluster or terminal display width.
Repair `split_label`; keep the input and output format.
Expected behavior
Every valid UTF-8 label splits without panic at the requested scalar-value count, preserving the full original text.
Reproduction
2 aéz
aé|z
3 server
ser|ver
Before you begin
- String slices
- UTF-8 byte offsets
- Character iteration
Need a nudge?
Reveal one investigation hint at a time. Try each clue before opening the next.
Read the report, then sign in to start your investigation.