Spot the bug in the UTF-8 prefix

from Strings
Rust 1.98 intermediate 4 min 1 issue to find

Find why this apparently bounded prefix helper can panic.

Rust
fn prefix(text: &str, max_bytes: usize) -> &str {
    &text[..max_bytes.min(text.len())]
}

fn main() {
    println!("{}", prefix("用户", 4));
}
Open in playground
Report an error