MCPcopy Index your code
hub / github.com/RustPython/RustPython / char_count_general_case

Function char_count_general_case

crates/wtf8/src/core_str_count.rs:118–122  ·  view source on GitHub ↗

This is the most direct implementation of the concept of "count the number of bytes in the string which are not continuation bytes", and is used for the head and tail of the input string (the first and last item in the tuple returned by `slice::align_to`).

(s: &[u8])

Source from the content-addressed store, hash-verified

116// head and tail of the input string (the first and last item in the tuple
117// returned by `slice::align_to`).
118fn char_count_general_case(s: &[u8]) -> usize {
119 s.iter()
120 .filter(|&&byte| !super::core_str::utf8_is_cont_byte(byte))
121 .count()
122}
123
124// polyfills of unstable library features
125

Callers 2

count_charsFunction · 0.85
do_count_charsFunction · 0.85

Calls 4

utf8_is_cont_byteFunction · 0.70
countMethod · 0.45
filterMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected