Better lowercase/uppercase checks

This commit is contained in:
Amos Wenger 2022-05-22 18:31:12 +02:00
parent 707a5683b1
commit 796c4d8a10
2 changed files with 2 additions and 2 deletions

View file

@ -41,7 +41,7 @@ pub(crate) fn generate_enum_variant(acc: &mut Assists, ctx: &AssistContext) -> O
}
let name_ref = path.segment()?.name_ref()?;
if name_ref.text().as_str().chars().next()?.is_ascii_lowercase() {
if name_ref.text().starts_with(char::is_lowercase) {
// Don't suggest generating variant if the name starts with a lowercase letter
return None;
}

View file

@ -73,7 +73,7 @@ fn gen_fn(acc: &mut Assists, ctx: &AssistContext) -> Option<()> {
Some(hir::PathResolution::Def(hir::ModuleDef::Adt(adt))) => {
if let hir::Adt::Enum(_) = adt {
// Don't suggest generating function if the name starts with an uppercase letter
if name_ref.text().chars().next()?.is_uppercase() {
if name_ref.text().starts_with(char::is_uppercase) {
return None;
}
}