Skip to content

Commit f2c91fc

Browse files
popzxcVeykril
andcommitted
Apply suggestions from code review
Co-authored-by: Lukas Wirth <[email protected]>
1 parent 9ea57ca commit f2c91fc

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

crates/hir_ty/src/diagnostics/decl_check/str_helpers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ enum DetectedCase {
1313
fn detect_case(ident: &str) -> DetectedCase {
1414
let trimmed_ident = ident.trim_matches('_');
1515
let first_lowercase =
16-
trimmed_ident.chars().next().map(|chr| chr.is_ascii_lowercase()).unwrap_or(false);
16+
trimmed_ident.starts_with(|chr| chr.is_ascii_lowercase());
1717
let mut has_lowercase = first_lowercase;
1818
let mut has_uppercase = false;
1919
let mut has_underscore = false;
@@ -102,7 +102,7 @@ pub fn to_camel_case(ident: &str) -> Option<String> {
102102
}
103103

104104
/// Converts an identifier to a lower_snake_case form.
105-
/// Returns `None` if the string is already is lower_snake_case.
105+
/// Returns `None` if the string is already in lower_snake_case.
106106
pub fn to_lower_snake_case(ident: &str) -> Option<String> {
107107
// First, assume that it's UPPER_SNAKE_CASE.
108108
match detect_case(ident) {

crates/stdx/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub fn to_lower_snake_case(s: &str) -> String {
3535
// `&& prev` is required to not insert `_` before the first symbol.
3636
if c.is_ascii_uppercase() && prev {
3737
// This check is required to not translate `Weird_Case` into `weird__case`.
38-
if buf.chars().last() != Some('_') {
38+
if !buf.ends_with('_') {
3939
buf.push('_')
4040
}
4141
}

0 commit comments

Comments
 (0)