From 30f6038cb9883084a3508b88dba83556a73ada8e Mon Sep 17 00:00:00 2001 From: "Heinz N. Gies" Date: Thu, 12 Oct 2023 11:46:15 +0200 Subject: [PATCH] lowercase support for rename all Signed-off-by: Heinz N. Gies --- simd-json-derive-int/src/args.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/simd-json-derive-int/src/args.rs b/simd-json-derive-int/src/args.rs index a1f2643..6b4d104 100644 --- a/simd-json-derive-int/src/args.rs +++ b/simd-json-derive-int/src/args.rs @@ -54,6 +54,7 @@ impl Parse for FieldAttrs { pub(crate) enum RenameAll { None, CamelCase, + Lowercase, } fn capitalize(field: &str) -> String { @@ -68,6 +69,7 @@ impl RenameAll { fn apply(&self, field: &str) -> String { match self { RenameAll::None => String::from(field), + RenameAll::Lowercase => field.to_lowercase(), RenameAll::CamelCase => { let mut parts = field.split('_'); let first = parts.next().expect("zero length name"); @@ -108,6 +110,7 @@ impl Parse for StructAttrs { match name.to_string().as_str() { r#""camelCase""# => rename_all = RenameAll::CamelCase, + r#""lowercase""# => rename_all = RenameAll::Lowercase, other => { return Err(syn::Error::new( attr.span(),