withoutboats / heck

oh heck, a case conversion library
Apache License 2.0
503 stars 34 forks source link

Consider supporting "UPPER CASE" #40

Closed nmlt closed 1 year ago

nmlt commented 1 year ago

There is already "Title Case" so it seems it would make sense to also support converting all letters to upper case and keeping the separator spaces.

jplatte commented 1 year ago

Can you explain what your use case is for this? I'm already not quite clear on what people use the title case conversion for.

nmlt commented 1 year ago

I'm using heck via strum, to convert my enum names to displayable strings. In this case I have an SQL operator enum, and would like to transform GroupBy to "GROUP BY".

jplatte commented 1 year ago

I don't really have time to maintain this crate anymore (I took over after withoutboats stopped maintaining it). I suggest looking for alternatives if what is there now doesn't suit your needs.

azaleacolburn commented 1 year ago

I can add UPPER CASE

jplatte commented 1 year ago

What actual use case do you have for this? Is it not filled by str::to_uppercase from std?

azaleacolburn commented 1 year ago

Word boundaries are represented as spaces in UPPER CASE, but remain unchanged in str::to_uppercase.

jplatte commented 1 year ago

Okay, but that only answers half of my question. What's your actual use case?

azaleacolburn commented 1 year ago

The same as the use-case for the entire crate. Case conversion, I don't personally use this library, but someone else might want this functionality(someone clearly does).

jplatte commented 1 year ago

Oh right, something was mentioned above. @nmlt is that code open-source? I would like to understand the context better.

azaleacolburn commented 1 year ago

I already opened a PR with the requested features

jplatte commented 1 year ago

I know, but I'm very hesitant about merging it. I never said I would accept a PR for it. If I were to add every casing rule imaginable, the API would be flooded with things most people have never heard of and will never need. There is another PR open with dot.case and an uppercase version of the same.

jplatte commented 1 year ago

I'm sorry but for now I'll close this. There is no obvious name for uppercase with spaces (or lowercase with spaces), and I have no reason to believe that they fill a significant use case so far. They can already be emulated with the current API (although it's not as efficient as proper support) by transforming to title case and calling .to_lowercase() or .to_uppercase() afterwards.

I'm open to reading about the mentioned use case in more detail, or reading about additional use cases. But without that, I'm not accepting PRs for this and will thus close the issue.

nmlt commented 1 year ago

Oh right, something was mentioned above. @nmlt is that code open-source? I would like to understand the context better.

The code is a mess and abandoned, but here’s my use case: https://github.com/nmlt/TeeBenchWeb/blob/fb15aaf9164d2c7902a172f28703f3570e724981/common/src/commit.rs#L11

I don’t think this will convince you, because I solved the issue with the strum macros: going from enum name “GroupBy” to “GROUP BY”.

Edit: to make the actual use case more clear: The enum represents a