1
Fork 0

Refactor is_snake_case.

This commit is contained in:
Diane Ringo 2025-03-13 20:31:59 -05:00
parent cbfdf0b014
commit b9f0ca11bc

View file

@ -274,18 +274,13 @@ impl NonSnakeCase {
let ident = ident.trim_start_matches('\''); let ident = ident.trim_start_matches('\'');
let ident = ident.trim_matches('_'); let ident = ident.trim_matches('_');
let mut allow_underscore = true; if ident.contains("__") {
ident.chars().all(|c| { return false;
allow_underscore = match c { }
'_' if !allow_underscore => return false,
'_' => false, // This correctly handles letters in languages with and without
// It would be more obvious to use `c.is_lowercase()`, // cases, as well as numbers and underscores.
// but some characters do not have a lowercase form !ident.chars().any(char::is_uppercase)
c if !c.is_uppercase() => true,
_ => return false,
};
true
})
} }
let name = ident.name.as_str(); let name = ident.name.as_str();