Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix camel_case to PascalCase bug #250

Merged

Conversation

bouzuya
Copy link
Contributor

@bouzuya bouzuya commented Jan 7, 2023

Specifying camel_case for serialize_all will result in a PascalCase. Is this the intended behavior?

This pull request assumes that this is unintended behavior and fixes it.


This is not related to this pull request, but I have a point of concern. If you allow a snake_case specification for each variant, I would like to see it supported for all variants. Otherwise, I think it would be a good idea to reject the camel_case and kebab_case specifications.

https://github.com/Peternator7/strum/pull/250/files#diff-801759161311a5149bd0d6c227fea4237bb6d8a8bb9e84f4703d305e2f131ae1R129

The serde crate rename_all attribute appears to reject it.

https://github.com/serde-rs/serde/blob/ce0844b9ecc32377b5e4545d759d385a8c46bc6a/serde_derive/src/internals/case.rs#L38-L59

@Peternator7
Copy link
Owner

Hi @bouzuya, I think this is an awkward case where it's by design. Heck (which provides the casing) refers to the cases as lowerCamelCase and UpperCamelCase so the original names for the case styles followed it's convention. As you noticed, the newer case-styles follow the pattern serde does of using the style itself in the name and that follows the more generally used convention of camelCase and PascalCase.

The docs recommend using the new naming format so I consider the old names to be soft-deprecated, but I don't think it's worth causing a breaking change by removing the old names or what they do.

@bouzuya bouzuya force-pushed the fix-camel-case-to-pascal-case-bug branch from d2fbcdc to b32ae96 Compare January 8, 2023 09:31
@bouzuya
Copy link
Contributor Author

bouzuya commented Jan 8, 2023

Thank you for your answer. I understood as follows.

  • Some people interpret camel_case as (upper_)camel_case (=PascalCase)
  • Names like camel_case are soft-deprecated
  • The documentation recommends camelCase.
  • Breaking changes by removing camel_case is not good for backward compatibility; removing camel_case is not worth it.

Based on your answer, I am going to stop changing the behavior (removing camel_case) and leave a comment stating that it is soft-deprecated.

@Peternator7 Peternator7 merged commit fcb9841 into Peternator7:master Jul 29, 2023
1 check passed
@bouzuya bouzuya deleted the fix-camel-case-to-pascal-case-bug branch July 31, 2023 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants