I'm writing my first tests in Rust and I find this:
warning: function
testCall
should have a snake case name such astest_call
, #[warn(non_snake_case)] on by default
after searching, I found this style guide.
I understand it is a convention, but is there some way to not show this warning?
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 .
There is a method in the Rust convention: Structs get camel case. Variables get snake case. Constants get all upper case.
Snake case (stylized as snake_case) refers to the style of writing in which each space is replaced by an underscore (_) character, and the first letter of each word is written in lowercase. It is a commonly used naming convention in computing, for example for variable and subroutine names, and for filenames.
You can use the allow
attribute as such:
#[allow(non_snake_case)] fn nonSnakeCase() {}
More on attributes here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With