File tree Expand file tree Collapse file tree 2 files changed +3
-3
lines changed
hir_ty/src/diagnostics/decl_check Expand file tree Collapse file tree 2 files changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ enum DetectedCase {
13
13
fn detect_case ( ident : & str ) -> DetectedCase {
14
14
let trimmed_ident = ident. trim_matches ( '_' ) ;
15
15
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 ( ) ) ;
17
17
let mut has_lowercase = first_lowercase;
18
18
let mut has_uppercase = false ;
19
19
let mut has_underscore = false ;
@@ -102,7 +102,7 @@ pub fn to_camel_case(ident: &str) -> Option<String> {
102
102
}
103
103
104
104
/// 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.
106
106
pub fn to_lower_snake_case ( ident : & str ) -> Option < String > {
107
107
// First, assume that it's UPPER_SNAKE_CASE.
108
108
match detect_case ( ident) {
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ pub fn to_lower_snake_case(s: &str) -> String {
35
35
// `&& prev` is required to not insert `_` before the first symbol.
36
36
if c. is_ascii_uppercase ( ) && prev {
37
37
// This check is required to not translate `Weird_Case` into `weird__case`.
38
- if buf. chars ( ) . last ( ) != Some ( '_' ) {
38
+ if ! buf. ends_with ( '_' ) {
39
39
buf. push ( '_' )
40
40
}
41
41
}
You can’t perform that action at this time.
0 commit comments