File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -887,13 +887,17 @@ impl NonSnakeCase {
887
887
fn to_snake_case ( str : & str ) -> String {
888
888
let mut words = vec ! [ ] ;
889
889
for s in str. split ( '_' ) {
890
+ let mut last_upper = false ;
890
891
let mut buf = String :: new ( ) ;
891
892
if s. is_empty ( ) { continue ; }
892
893
for ch in s. chars ( ) {
893
- if !buf. is_empty ( ) && buf. as_slice ( ) != "'" && ch. is_uppercase ( ) {
894
+ if !buf. is_empty ( ) && buf. as_slice ( ) != "'"
895
+ && ch. is_uppercase ( )
896
+ && !last_upper {
894
897
words. push ( buf) ;
895
898
buf = String :: new ( ) ;
896
899
}
900
+ last_upper = ch. is_uppercase ( ) ;
897
901
buf. push_char ( ch. to_lowercase ( ) ) ;
898
902
}
899
903
words. push ( buf) ;
Original file line number Diff line number Diff line change @@ -23,11 +23,14 @@ impl Foo {
23
23
24
24
pub fn xyZ ( & mut self ) { }
25
25
//~^ ERROR method `xyZ` should have a snake case name such as `xy_z`
26
+
27
+ fn render_HTML ( ) { }
28
+ //~^ ERROR method `render_HTML` should have a snake case name such as `render_html`
26
29
}
27
30
28
31
trait X {
29
32
fn ABC ( ) ;
30
- //~^ ERROR trait method `ABC` should have a snake case name such as `a_b_c `
33
+ //~^ ERROR trait method `ABC` should have a snake case name such as `abc `
31
34
32
35
fn a_b_C ( & self ) { }
33
36
//~^ ERROR trait method `a_b_C` should have a snake case name such as `a_b_c`
You can’t perform that action at this time.
0 commit comments