Use the external cargo-tarpaulin tool to generate an HTML report showing which lines of Rust code are executed by your tests.
Rust does not have a built-in command to measure code coverage; you must use the cargo-tarpaulin tool. Install it and run it with the --out flag to generate an HTML report in your project directory.
cargo install cargo-tarpaulin
cargo tarpaulin --out Html
Open the generated tarpaulin-report.html file in your browser to see the coverage details.
Code coverage tells you what percentage of your code is actually run when your tests execute. It helps you find parts of your program that you forgot to test. Think of it like a highlighter that marks every line of code your tests touch, so you can see exactly which lines are still untested.