[ 
https://issues.apache.org/jira/browse/THRIFT-4529?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16682477#comment-16682477
 ] 

Allen George edited comment on THRIFT-4529 at 11/10/18 3:53 PM:
----------------------------------------------------------------

Humorously (I guess this is the story of all programming) this turns out to be 
more complicated than expected.

There are a few cases. I've outlined the cases and the rust-compatible outcome:

1. All lowercase. "foo" => "Foo"
2. All uppercase. "FOO" => "Foo"
3. Screaming snake case (most common, I'd assume). "SCREAMING_SNAKE_CASE" => 
"ScreamingSnakeCase"
4. Snake case. "snake_case" => "SnakeCase"
4. Camel case. "CamelCase" => "CamelCase"

I'm going to hope no one does something bizarre like some mutated combination 
of snake and camelcase (for example "Mutant_Case").

The problem is, we have to figure out which one of the situations we're dealing 
with, because the conversions we'll perform will differ for every one, which is 
supremely annoying. I tried to avoid having to differentiate between the cases, 
but, the default implementations of {{t_generator::camelcase}} and 
{{t_generator::uppercase}} make this impossible.


was (Author: allengeorge):
Humorously (I guess this is the story of all programming) this turns out to be 
more complicated than expected.

There are a few cases. I've outlined the cases and the rust-compatible outcome:

1. All lowercase. "foo" => "Foo"
2. All uppercase. "FOO" => "Foo"
3. Screaming snake case (most common, I'd assume). "SCREAMING_SNAKE_CASE" => 
"ScreamingSnakeCase"
4. Snake case. "snake_case" => "SnakeCase"
4. Camel case. "CamelCase" => "CamelCase"

The problem is, we have to figure out which one of the situations we're dealing 
with, because the conversions we'll perform will differ for every one, which is 
supremely annoying. I tried to avoid having to differentiate between the cases, 
but, the default implementations of {{t_generator::camelcase}} and 
{{t_generator::uppercase}} make this impossible.

> Rust generation should include #![allow(non_snake_case)] or force conform to 
> Rust style guidelines
> --------------------------------------------------------------------------------------------------
>
>                 Key: THRIFT-4529
>                 URL: https://issues.apache.org/jira/browse/THRIFT-4529
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Rust - Compiler
>    Affects Versions: 0.11.0
>            Reporter: Joshua
>            Assignee: Allen George
>            Priority: Minor
>
> Without this, building a project using a thrift file meant for multiple 
> languages may end up with many compiler warnings similar to the following:
> {code:sh}
> warning: variant `EXAMPLE_NAME` should have a camel case name such as 
> `ExampleName`
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to