Skip to content
This repository has been archived by the owner on Oct 6, 2024. It is now read-only.

Added test for lower casing corner case + fix #61

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bogdanstate
Copy link

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 both paste to convert it to lower snake case when it's an identifier, as well as inflector when it's a value. paste converts the string as a_c_m_e_corp, whereas inflector converts it to acme_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 ACMECorp identifier. I got it to fail, and tried to change the original implementation to match the inflector behavior, 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 on inflector.

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.

@bogdanstate
Copy link
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 aorist_paste. I preserved the license in the crate, gave credit to @dtolnay as the main author and added my name as the crate maintainer. Hoping this is okay -- will yank the crate once I either find a more elegant way to deal with this issue myself or once it's fixed in the paste crate.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant