@@ -1105,18 +1105,10 @@ fn test_omit_init_build() {
1105
1105
) ;
1106
1106
}
1107
1107
1108
-
1109
1108
pub trait ConvertStringCase {
1110
1109
fn convert_string_case ( s : & str ) -> String ;
1111
1110
}
1112
1111
1113
- struct IdentityConverter ;
1114
- impl ConvertStringCase for IdentityConverter {
1115
- fn convert_string_case < ' a > ( s : & ' a str ) -> String {
1116
- s. to_string ( )
1117
- }
1118
- }
1119
-
1120
1112
struct CamelCaseConverter ;
1121
1113
impl ConvertStringCase for CamelCaseConverter {
1122
1114
fn convert_string_case < ' a > ( s : & ' a str ) -> String {
@@ -1125,6 +1117,22 @@ impl ConvertStringCase for CamelCaseConverter {
1125
1117
}
1126
1118
}
1127
1119
1120
+ struct KebabCaseConverter ;
1121
+ impl ConvertStringCase for KebabCaseConverter {
1122
+ fn convert_string_case < ' a > ( s : & ' a str ) -> String {
1123
+ use heck:: KebabCase ;
1124
+ s. to_kebab_case ( ) . to_string ( )
1125
+ }
1126
+ }
1127
+
1128
+ struct SnakeCaseConverter ;
1129
+ impl ConvertStringCase for SnakeCaseConverter {
1130
+ fn convert_string_case < ' a > ( s : & ' a str ) -> String {
1131
+ use heck:: SnakeCase ;
1132
+ s. to_snake_case ( ) . to_string ( )
1133
+ }
1134
+ }
1135
+
1128
1136
fn test_init_impl < T : ConvertStringCase > ( ) {
1129
1137
use serde_json:: json;
1130
1138
@@ -1165,13 +1173,18 @@ fn test_init_impl<T:ConvertStringCase>() {
1165
1173
}
1166
1174
1167
1175
#[ test]
1168
- fn test_init_with_configuration ( ) {
1169
- test_init_impl :: < IdentityConverter > ( ) ;
1176
+ fn test_init_with_configuration_camel_case ( ) {
1177
+ test_init_impl :: < CamelCaseConverter > ( ) ;
1178
+ }
1179
+
1180
+ #[ test]
1181
+ fn test_init_with_configuration_kebab_case ( ) {
1182
+ test_init_impl :: < KebabCaseConverter > ( ) ;
1170
1183
}
1171
1184
1172
1185
#[ test]
1173
- fn test_init_with_configuration_camel_case ( ) {
1174
- test_init_impl :: < CamelCaseConverter > ( ) ;
1186
+ fn test_init_with_configuration_snake_case ( ) {
1187
+ test_init_impl :: < SnakeCaseConverter > ( ) ;
1175
1188
}
1176
1189
1177
1190
#[ test]
0 commit comments