Skip to content

Commit 796c4d8

Browse files
Better lowercase/uppercase checks
1 parent 707a568 commit 796c4d8

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

crates/ide-assists/src/handlers/generate_enum_variant.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub(crate) fn generate_enum_variant(acc: &mut Assists, ctx: &AssistContext) -> O
4141
}
4242

4343
let name_ref = path.segment()?.name_ref()?;
44-
if name_ref.text().as_str().chars().next()?.is_ascii_lowercase() {
44+
if name_ref.text().starts_with(char::is_lowercase) {
4545
// Don't suggest generating variant if the name starts with a lowercase letter
4646
return None;
4747
}

crates/ide-assists/src/handlers/generate_function.rs

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

0 commit comments

Comments
 (0)