cargo-llvm-cov tool can be used to generate coverage stats, HTML reports, and lcov files that IDEs will load to display the coverage in the code editor.
Install cargo-llvm-cov before proceeding with the other commands.
How to Get Coverage Stats
Run the test subcommand that will run the tests and output the stats per file.How to Generate a Coverage Report with Code
Run the test subcommand that will run the tests and output a set of HTML files showing which lines of code are covered.How to Generate an LCOV File for IDEs
Run the test subcommand that will run the tests and output a singlelcov.info file.
lcov.info file into your IDE using its coverage feature. In VSCode this can be done by installing the Coverage Gutters extension and executing the Coverage Gutters: Watch command.
Measuring code coverage in fuzz tests requires different tooling. See Fuzzing.