June 2021
Beginner
344 pages
8h 9m
English
Rust ships with a tool called Clippy. Clippy provides hints and guidance while you code. You can type cargo clippy at any time to get a list of suggestions for your project. Many clippy warnings will also appear when you compile your programs. Most development environments that support Rust integrate with Clippy and will show you warnings and hints as you work.
Let’s use Clippy to fix a simple project. Create a new project by navigating to your source code folder and typing cargo new clippy (see Starting a New Project with Cargo). Edit your src/main.rs file to contain the following:
| | fn main() { |
| | let MYLIST = [ "One", "Two", "Three" ]; |
| | for i in 0..3 { |
| |
Read now
Unlock full access