Background
Rust is really finicky in terms of naming convention.
Lineage
- Rust:- Build Warning – “crate should have a snake case name” – Workaround – Ignore
Date Posted:- 2022-September-15th
Link
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
- Project Creation
- 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
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
- Project
- Rename
- Clean
- Build
Project
Rename Project
Outline
- Project
- Rename
- Rename project from helloWorld to hello_world
- The change needs to be applied to the manifest file ( Cargo.toml )
- Rename
Cargo.toml
Image
Image – Original
Image – Revise
Text
[package] #dadeniji 2022-09-15 06:15 AM #project renamed from 'helloWorld' to 'hello_world' #name = "helloWorld" name = "hello_world" version = "0.1.0" edition = "2021"
Clean Project
Outline
- Project
- Clean
- Clean Project
- When a rust project is built, files are created based on what is in the manifest file
- Let us remove files created from previous build by issuing “cargo clean“.
- Clean Project
- Clean
Command
Syntax
cargo clean
Sample
cargo clean
Output
Image
Text
>cargo clean >
build
cargo build
Outline
- Project
- Build
- Build Project
- Let us re-build the project
- Build Project
- Build
Syntax
cargo build
Sample
cargo build --release --quiet
Output
Image
Text
>cargo build --release --quiet >
Explanation
We have a clean build.
Review
Review Built Files
Directory Structure
File Listing
Please review the target\release folder.
Syntax
dir [folder]
Sample
dir target\release\hello*
Output
Images
Text
Here are some of the files created:-
- hello_world.d
- hello_world.exe
- hello_world.pdb
Summary
In follow up posts, we will cover more ways we can customize the metadata file ( Cargo.toml ).
[…] Rust:- Build Warning – “crate should have a snake case name” – Project Rename Date Posted:- 2022-September-15th Link […]