How to Write Documentation Comments in Rust (/// and //!)

Use /// for item documentation and //! for crate-level documentation to generate API docs with rustdoc.

Use /// for single-line documentation comments and //! for single-line crate-level documentation comments. Both are processed by rustdoc to generate API documentation, unlike standard // comments which are ignored.

/// This is a single-line doc comment for a function.
fn greet() {
    println!("Hello");
}

//! This is a crate-level doc comment.
//! It appears at the top of the crate root file.

pub fn main() {}