dom_query 0.27.0

HTML querying and manipulation with CSS selectors
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
pub(crate) fn normalized_char_count(text: &str, start_whitespace: bool) -> usize {
    let mut char_count = 0;
    let mut prev_was_whitespace = start_whitespace;

    for c in text.chars() {
        let is_ws = c.is_whitespace();
        if !(prev_was_whitespace && is_ws) {
            char_count += 1;
        }
        prev_was_whitespace = is_ws;
    }
    char_count
}