Unit tests

Annotate a function with `#[test]` and call `cargo test` to run it. Convention puts unit tests inside a `#[cfg(test)] mod tests { ... }` block at the bottom of the source file.

For deeper background, see the canonical Rust learning roadmap for the broader context behind this section.

Integration tests

Files inside the `tests/` directory at the crate root are compiled as separate binaries and have access only to the crate's public API. Use them to test what your users will see.

Doctests

Triple-slash `///` comments are documentation. Code blocks inside them are compiled and run by `cargo test`, ensuring your examples never go stale.

Documentation conventions

`cargo doc --open` builds and opens the docs. Idiomatic crates document every public item with a one-line summary, a longer explanation, and a runnable example.