pub open spec fn length_of_last_scalar(bytes: Seq<u8>) -> intExpand description
recommends
valid_utf8(bytes),bytes.len() > 0,{
let n = bytes.len() as int;
if !is_continuation_byte(bytes[n - 1]) {
1
} else if !is_continuation_byte(bytes[n - 2]) {
2
} else if !is_continuation_byte(bytes[n - 3]) {
3
} else {
4
}
}The length in bytes of the last scalar encoded in UTF-8 in the given byte sequence, assuming that the bytes form a valid UTF-8 encoding.