Lab 3. Introduction to Rust
Due: 2024-09-30 at 23:59
Preliminaries
First, find a partner. You’re allowed to work by yourself, but I highly recommend working with a partner. If you choose to work with a partner, you and your partner must complete the entire project together, as a single repository. Dividing the project up into sections and having each partner complete a part of it on their own will be considered a violation of the honor code. Both you and your partner are expected to fully understand all of the code you submit.
Click on the assignment link. One partner should create a new team. The team name cannot be the same name used for a previous lab. The second partner should click the link and choose the appropriate team. (Please don’t choose the wrong team, there’s a maximum of two people and if you join the wrong one, you’ll prevent the correct person from joining.) You cannot choose a team name you’ve used previously.
Once you have accepted the assignment and created/joined a team, you can clone the repository and begin working.
Be sure to ask any questions on Ed.
Compiler warnings and errors
Make sure your code compiles and passes clippy
without errors or warnings.
That is, running
$ cargo clean
$ cargo build
$ cargo clippy
should build your program without errors or warnings. Running these commands
will only work if you have cd
ed into a Rust project directory.
Cargo’s clippy
is a command-line utility for linting Rust code. A linter automatically analyzes source code for errors, vulnerabilities, and stylistic issues to improve code quality. Cargo clippy
will provide suggestions and warnings for potential errors in your code, such as unused variables, unnecessary operations, and more. For example, it will suggest more efficient ways of writing your code and point out common pitfalls that could lead to runtime errors.
VS Code doesn’t always update its error underlining until after you save your file. So make sure to do that with some regularity while you’re writing code.
Formatting
Your code must be formatted by running $ cargo fmt
. This will automatically format your code in a consistent Rust style.
To get started, continue on to Part 1!