Skip to content

Commit

Permalink
lowercase support for rename all
Browse files Browse the repository at this point in the history
Signed-off-by: Heinz N. Gies <[email protected]>
  • Loading branch information
Licenser committed Oct 14, 2023
1 parent 3dfecce commit 30f6038
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions simd-json-derive-int/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ impl Parse for FieldAttrs {
pub(crate) enum RenameAll {
None,
CamelCase,
Lowercase,
}

fn capitalize(field: &str) -> String {
Expand All @@ -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");
Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit 30f6038

Please sign in to comment.