Rust:- Build Warning – “crate should have a snake case name” – Workaround – Ignore

Background

Rust is really finicky in terms of naming convention.

Error Message

Image

Text


	warning: crate `helloWorld` should have a snake case name
	  |
	  = note: `#[warn(non_snake_case)]` on by default
	  = help: convert the identifier to snake case: `hello_world`

Troubleshooting

Outline

  1. Project Creation
  2. Manifest File ( Cargo.toml )

Project Creation

Here is the command we used to create the project.

Image

Text


cargo new helloWorld --bin

 

Manifest File ( Cargo.toml )

Running “cargo new” creates a manifest file.

Here is what it looks like.

Image

Text


[package]
name = "helloWorld"
version = "0.1.0"
edition = "2021"

Explanation

The project’s name is reflected in the package section; under name.

 

Naming Convention

Camel Case

Wikipedia

Link

Camel case (sometimes stylized as camelCase or CamelCase, also known as camel caps or more formally as medial capitals) is the practice of writing phrases without spaces or punctuation. It indicates the separation of words with a single capitalized letter, and the first word starting with either case. Common examples include “iPhone” and “eBay”. It is also sometimes used in online usernames such as “johnSmith”, and to make multi-word domain names more legible, for example in promoting “EasyWidgetCompany.com”.

Camel case is often used as a naming convention in computer programming, but is an ambiguous definition due to the optional capitalization of the first letter. Some programming styles prefer camel case with the first letter capitalised, others not.  For clarity, this article calls the two alternatives upper camel case (initial uppercase letter, also known as Pascal case or bumpy case) and lower camel case (initial lowercase letter, also known as dromedary case). Some people and organizations, notably Microsoft, use the term camel case only for lower camel case, designating Pascal case for the upper camel case.

 

Workaround

Outline

  1. Source Code
    • File Directive

Source Code

File Directive

Outline

  1. File level directive
    • Add a file level directive to allow non snake case
      • #![allow(non_snake_case)]

Image

Text


#![allow(non_snake_case)]

 

Validate

Once we added the module level ignore directive, it is time to retest.

build

cargo build

Syntax


cargo build

Sample


cargo build --release --quiet

Output

Image

Text

>cargo build --release --quiet

>

Explanation

We have a clean build.

In choosing to ignore the warning, we can move on.

Crediting

Aleksey Kladov ( matklad )

Crediting Aleksey Kladov ( matklad ).

Profile here.

Profile reads:-

  1. matklad, hater of linked lists.
  2. I’ve also helped to build Intellij-Rust and rust-analyzer

There are ___ that matter in this business and life in general.

A few people it is like what can I share.

Most Others, it be:-

  1. I am entitled to that
  2. What can I get more of
  3. What can I take or outright stole

I be like Bro, “Holla Less“.

 

References

  1. rust-lang.org
    • Turning off compiler warning messages
      Link
  2. Wikipedia

2 thoughts on “Rust:- Build Warning – “crate should have a snake case name” – Workaround – Ignore

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s