File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -28,10 +28,24 @@ impl Case {
28
28
Cow :: Borrowed ( s) if s. is_constant_case ( ) => cow,
29
29
_ => cow. to_constant_case ( ) . into ( ) ,
30
30
} ,
31
- Self :: Pascal => match cow {
32
- Cow :: Borrowed ( s) if s. is_pascal_case ( ) => cow,
33
- _ => cow. to_pascal_case ( ) . into ( ) ,
34
- } ,
31
+ Self :: Pascal => {
32
+ if let Some ( ( first, _) ) = cow
33
+ . char_indices ( )
34
+ . find ( |( _, c) | c != & '_' && !c. is_ascii_digit ( ) )
35
+ {
36
+ if first != 0 {
37
+ let ( prefix, s) = cow. split_at ( first) ;
38
+ format ! ( "{prefix}{}" , s. to_pascal_case( ) ) . into ( )
39
+ } else {
40
+ match cow {
41
+ Cow :: Borrowed ( s) if s. is_pascal_case ( ) => cow,
42
+ _ => cow. to_pascal_case ( ) . into ( ) ,
43
+ }
44
+ }
45
+ } else {
46
+ cow
47
+ }
48
+ }
35
49
Self :: Snake => match cow {
36
50
Cow :: Borrowed ( s) if s. is_snake_case ( ) => cow,
37
51
_ => cow. to_snake_case ( ) . into ( ) ,
You can’t perform that action at this time.
0 commit comments