100-exercises-to-learn-rust
100-exercises-to-learn-rust copied to clipboard
Consider Adding #[allow(dead_code)] To Examples
These examples are great, but when the student successfully completes the exercise there are still a bunch of warnings in the output.
eg:
02_match test pass! 2 warnings
1 warning: enum `Shape` is never used
--> exercises/05_ticket_v2/02_match/src/lib.rs:2:6
|
2 | enum Shape {
| ^^^^^
|
= note: `#[warn(dead_code)]` on by default
2 warning: method `n_sides` is never used
--> exercises/05_ticket_v2/02_match/src/lib.rs:13:12
|
10 | impl Shape {
| ---------- method in this implementation
...
13 | pub fn n_sides(&self) -> u8 {
| ^^^^^^^
Consider annotating the Shape enum and n_sides functions here with the attribute macro #[allow(dead_code)] so that the output is green and lovely:
02_match test pass!
▐
running 5 tests ▐
test tests::test_circle ... ok ▐
test tests::test_pentagon ... ok ▐
test tests::test_rectangle ... ok ▐
test tests::test_square ... ok ▐
test tests::test_triangle ... ok ▐
▐
test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished i ▐
n 0.00s ▐
▐
Doc-tests match_
running 0 tests
I can help with this if you decide you want to update all the examples to include this. 👍
Or even better, maybe there is a way to add it to one overall Cargo.toml file?
For exercises up to the visibility chapter, I've now ignored dead code warnings.
For exercises after the visibility chapter, we should ensure that the relevant code is marked as pub to suppress that warning.
Leaving this issue open until the second item has been addressed.