From f2c91fc5a8c22b8ac80f100b2b666f2dc9baa67c Mon Sep 17 00:00:00 2001 From: Igor Aleksanov Date: Mon, 5 Oct 2020 19:34:23 +0300 Subject: Apply suggestions from code review Co-authored-by: Lukas Wirth --- crates/hir_ty/src/diagnostics/decl_check/str_helpers.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/hir_ty/src/diagnostics/decl_check/str_helpers.rs') diff --git a/crates/hir_ty/src/diagnostics/decl_check/str_helpers.rs b/crates/hir_ty/src/diagnostics/decl_check/str_helpers.rs index 8f70c5e84..c1ab1a675 100644 --- a/crates/hir_ty/src/diagnostics/decl_check/str_helpers.rs +++ b/crates/hir_ty/src/diagnostics/decl_check/str_helpers.rs @@ -13,7 +13,7 @@ enum DetectedCase { fn detect_case(ident: &str) -> DetectedCase { let trimmed_ident = ident.trim_matches('_'); let first_lowercase = - trimmed_ident.chars().next().map(|chr| chr.is_ascii_lowercase()).unwrap_or(false); + trimmed_ident.starts_with(|chr| chr.is_ascii_lowercase()); let mut has_lowercase = first_lowercase; let mut has_uppercase = false; let mut has_underscore = false; @@ -102,7 +102,7 @@ pub fn to_camel_case(ident: &str) -> Option { } /// Converts an identifier to a lower_snake_case form. -/// Returns `None` if the string is already is lower_snake_case. +/// Returns `None` if the string is already in lower_snake_case. pub fn to_lower_snake_case(ident: &str) -> Option { // First, assume that it's UPPER_SNAKE_CASE. match detect_case(ident) { -- cgit v1.2.3