How to Write Examples for Your Rust Crate

Add a # Examples section in doc comments with a runnable code block to demonstrate function usage and verify correctness.

Write examples in doc comments using the # Examples section followed by a fenced code block that demonstrates usage and asserts the result.

/// Adds one to the number given.
///
/// # Examples
///
/// ```
/// let arg = 5;
/// let answer = my_crate::add_one(arg);
///
/// assert_eq!(6, answer);
/// ```
pub fn add_one(x: i32) -> i32 {
    x + 1
}