fix(linter): fix no_unused_vars panic when encountering unicode (#5582)

closes #4887
This commit is contained in:
Boshen 2024-09-07 12:37:51 +00:00
parent 5f275516eb
commit 3b87ac48ce

View file

@ -10,5 +10,5 @@ use super::{NoUnusedVars, Symbol};
// getting cast to a u32
#[allow(clippy::cast_possible_truncation)]
fn count_whitespace_or_commas<I: Iterator<Item = char>>(iter: I) -> u32 {
iter.take_while(|c| c.is_whitespace() || *c == ',').count() as u32
iter.take_while(|c| *c == ',' || c.is_whitespace()).map(|c| c.len_utf8() as u32).sum()
}