-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
use heck for string casing #4081
Conversation
I also am depending on a commit because the latest stable release does not have Upper Camel Case (our PascalCase). |
@efx I'm not sure we can use it if the crate isn't published. I think it prevents us releasing a new release. |
Ah, thanks for the heads up @fdncred. |
@efx - did you hear anything back? |
@jntrnr apologies on the delay! I have not unfortunately. I'll ping again. Do you have a preference for how I manage this open PR? Thanks! |
not sure what's going on with the CI system but it's puking for no reason. we should wait a few hours and retrigger i think. |
can you push an empty commit. I can't restart the ci. |
LOL, it seems like macOS-10.14 is deprecated as of 12/10/2021: Azure/azure-sdk-for-cpp#3168. |
i reran the mac CI and it still said the same errors. you may need to close this and resubmit it since i just landed your CI fix. |
I removed the Inflector dependency in favor of heck for two reasons: - to close #3674. - heck seems simpler and actively maintained We could probably alter the structure of the `str_` module to expose the individual casing behaviors better. I did not feel as confident on changing those signatures. So I took a lazier approach of a macro in the `mod.rs` that creates the public shimming function to heck's traits.
Thank you for running that! I went ahead and rebased with the latest CI fixes. |
ok, good. crossing my fingers. |
finally! thanks @efx |
Re-fixes #3674, if that is seen as desirable to do. # Description This PR changes the implementation of the `--features=extra` string casing commands from Inflector to `heck`, as in PR #4081. This PR landed a long time ago, but somewhere along the way (i can't find it) the implementation ended up being switched back to Inflector. # User-Facing Changes Inflector and `heck` implement casing differently, so all of the commands have different behavior around edge cases (consecutive capitals, interspersed numbers and letters, etc) ### Before ```nu G:/Dev/nu-itself/nushell> [UserID ABCdefGHI foo123bar] | str camel-case ╭───┬───────────╮ │ 0 │ userID │ │ 1 │ abcdefGHI │ │ 2 │ foo123Bar │ ╰───┴───────────╯ G:/Dev/nu-itself/nushell> [UserID ABCdefGHI foo123bar] | str snake-case ╭───┬─────────────╮ │ 0 │ user_id │ │ 1 │ ab_cdef_ghi │ │ 2 │ foo_12_3bar │ ╰───┴─────────────╯ ``` ### After ```nu G:/Dev/nu-itself/nushell> [UserID ABCdefGHI foo123bar] | str camel-case ╭───┬───────────╮ │ 0 │ userId │ │ 1 │ abCdefGhi │ │ 2 │ foo123bar │ ╰───┴───────────╯ G:/Dev/nu-itself/nushell> [UserID ABCdefGHI foo123bar] | str snake-case ╭───┬─────────────╮ │ 0 │ user_id │ │ 1 │ ab_cdef_ghi │ │ 2 │ foo123bar │ ╰───┴─────────────╯ ``` # Tests + Formatting The existing string casing tests pass... because none of them relied on any of these edge cases
Re-fixes nushell#3674, if that is seen as desirable to do. # Description This PR changes the implementation of the `--features=extra` string casing commands from Inflector to `heck`, as in PR nushell#4081. This PR landed a long time ago, but somewhere along the way (i can't find it) the implementation ended up being switched back to Inflector. # User-Facing Changes Inflector and `heck` implement casing differently, so all of the commands have different behavior around edge cases (consecutive capitals, interspersed numbers and letters, etc) ### Before ```nu G:/Dev/nu-itself/nushell> [UserID ABCdefGHI foo123bar] | str camel-case ╭───┬───────────╮ │ 0 │ userID │ │ 1 │ abcdefGHI │ │ 2 │ foo123Bar │ ╰───┴───────────╯ G:/Dev/nu-itself/nushell> [UserID ABCdefGHI foo123bar] | str snake-case ╭───┬─────────────╮ │ 0 │ user_id │ │ 1 │ ab_cdef_ghi │ │ 2 │ foo_12_3bar │ ╰───┴─────────────╯ ``` ### After ```nu G:/Dev/nu-itself/nushell> [UserID ABCdefGHI foo123bar] | str camel-case ╭───┬───────────╮ │ 0 │ userId │ │ 1 │ abCdefGhi │ │ 2 │ foo123bar │ ╰───┴───────────╯ G:/Dev/nu-itself/nushell> [UserID ABCdefGHI foo123bar] | str snake-case ╭───┬─────────────╮ │ 0 │ user_id │ │ 1 │ ab_cdef_ghi │ │ 2 │ foo123bar │ ╰───┴─────────────╯ ``` # Tests + Formatting The existing string casing tests pass... because none of them relied on any of these edge cases
I removed the Inflector dependency in favor of heck for two reasons:
We could probably alter the structure of the
str_
module to expose theindividual casing behaviors better.
I did not feel as confident on changing those signatures.
So I took a lazier approach of a macro in the
mod.rs
that creates the publicshimming function to heck's traits.