Write crate-level documentation by adding `//!` comments at the top of your library's root file.
Place //! comments at the very top of your library's root file (usually src/lib.rs) to write crate-level documentation that appears in the generated docs.
//! # Crate Name
//!
//! This is the crate-level documentation.
//! It appears at the top of the generated documentation page.
pub fn hello() {
println!("Hello");
}
Run cargo doc --open to view the rendered documentation in your browser.
Crate-level documentation is the main introduction for your entire Rust library, similar to the cover page of a book. You write it using //! comments at the very top of your main library file so that anyone reading your documentation sees it first. This helps users understand what your library does before they dive into specific functions.