File tree Expand file tree Collapse file tree
packages/schema/bind/src/bindings/rust Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -316,7 +316,7 @@ export const serdeKeyword: MustacheFn = () => {
316316
317317export const serdeRenameIfSnakeCase : MustacheFn = ( ) => {
318318 return ( value : string , render : ( template : string ) => string ) : string => {
319- let type = render ( value ) ;
319+ const type = render ( value ) ;
320320
321321 if ( isSnakeCase ( type ) ) {
322322 return `#[serde(rename = "${ snakeCaseToCamelCase ( type ) } ")]\n ` ;
@@ -326,13 +326,15 @@ export const serdeRenameIfSnakeCase: MustacheFn = () => {
326326 return `#[serde(rename = "${ type } ")]\n ` ;
327327 }
328328 return "" ;
329- } ;
330- }
329+ } ;
330+ } ;
331331
332- const isSnakeCase = ( value : string ) : boolean => / [ a - z 0 - 9 ] + (?: _ [ a - z 0 - 9 ] + ) * / . test ( value ) && value . includes ( "_" )
333- const snakeCaseToCamelCase = ( value : string ) : string => value . toLowerCase ( ) . replace (
334- / [ - _ ] [ a - z ] / g, ( group ) => group . slice ( - 1 ) . toUpperCase ( )
335- )
332+ const isSnakeCase = ( value : string ) : boolean =>
333+ / [ a - z 0 - 9 ] + (?: _ [ a - z 0 - 9 ] + ) * / . test ( value ) && value . includes ( "_" ) ;
334+ const snakeCaseToCamelCase = ( value : string ) : string =>
335+ value
336+ . toLowerCase ( )
337+ . replace ( / [ - _ ] [ a - z ] / g, ( group ) => group . slice ( - 1 ) . toUpperCase ( ) ) ;
336338
337339const toWasmArray = ( type : string , optional : boolean ) : string => {
338340 const result = type . match ( / ( \[ ) ( [ [ \] A - Z a - z 1 - 9 _ . ! ] + ) ( \] ) / ) ;
You can’t perform that action at this time.
0 commit comments