Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable camel case warnings

Tags:

rust

This wasn't on google, so I kindly ask someone how to supress this warning:

342 |     BAYER_RGGB16,
    |     ^^^^^^^^^^^^ help: convert the identifier to upper camel case: `BayerRggb16`

#[allow(non_snake_case)] doesn't work.

like image 758
Guerlando OCs Avatar asked Oct 14 '20 23:10

Guerlando OCs


People also ask

How do I turn off Snake Case warning rust?

rustc has some built-in warnings that enforce standard code style, such as lower-snake-case names for local variables and functions vs. upper-snake-case names for constants and statics. You can turn these off completely by putting #![ allow(nonstandard-style)] in your lib.rs or main.rs .

What is the point of camel case?

CamelCase is a way to separate the words in a phrase by making the first letter of each word capitalized and not using spaces. It is commonly used in web URLs, programming and computer naming conventions. It is named after camels because the capital letters resemble the humps on a camel's back.

What is CamelCase example?

Meaning of camel case in English. the use of a capital letter to begin the second word in a compound name or phrase, when it is not separated from the first word by a space: Examples of camel case include "iPod" and "GaGa".

What is the difference between camel case and Pascal case?

Camel case and Pascal case are similar. Both demand variables made from compound words and have the first letter of each appended word written with an uppercase letter. The difference is that Pascal case requires the first letter to be uppercase as well, while camel case does not.


1 Answers

You're looking for the lint option non-camel-case-types. The description of this check from rustc -W help reads

                           name default meaning
non-camel-case-types warn types, variants, traits and type parameters should have camel case names

In your snippet, BAYER_RGGB16 appears to be an enum variant, so the default lint options require it to be named in (upper) CamelCase. This check can be disabled with the lint attribute #[allow(non_camel_case_types)]:

// Can also be applied to the whole enum, instead of just one variant.
// #[allow(non_camel_case_types)]
enum MyEnum {

    // ...

    #[allow(non_camel_case_types)]
    BAYER_RGGB16,
}

Try it yourself on the Rust Playground.

like image 56
Brian Avatar answered Oct 20 '22 23:10

Brian