This repository was archived by the owner on Oct 6, 2024. It is now read-only.
Added test for lower casing corner case + fix#61
Open
bogdanstate wants to merge 1 commit intodtolnay:masterfrom
Open
Added test for lower casing corner case + fix#61bogdanstate wants to merge 1 commit intodtolnay:masterfrom
bogdanstate wants to merge 1 commit intodtolnay:masterfrom
Conversation
Author
|
Just a quick note on this PR. I really need to use this behavior in a project I am about to publish on crates.io. Given the widespread use of paste in Rust, I understand why you might not want to add a dependency on Inflector. This is why I published a crate associated with my fork (which contains the proposed fix) as |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thanks for the really nifty crate! I came across a small issue recently when writing a program that makes heavy use of meta-programming, including of the paste crate.
I have a string of the form
ACMECorp. I use bothpasteto convert it to lower snake case when it's an identifier, as well asinflectorwhen it's a value.pasteconverts the string asa_c_m_e_corp, whereasinflectorconverts it toacme_corp. To me, the latter solution feels like the more idiomatic way to do this case conversion.I was able to reproduce this example by writing a test against the
ACMECorpidentifier. I got it to fail, and tried to change the original implementation to match theinflectorbehavior, but the logic turned out to be too complex. And indeed, in the inflector code, there is quite a bit more logic dealing with this sort of complexity. So I gave up and added a dependency oninflector.I noticed that you have no other dependencies in this crate, so I don't know to what extent this is okay as far as the main branch is concerned, but this does solve my own problem for the time being. I figured I would share what I have so far, since this is a working solution for a small but surprisingly annoying problem.