Dokumentationstests

Rust comes with extensive documentation. For example:

In fact, you can document your own code:

/// Determine whether the first argument is divisible by the second argument.
///
/// If the second argument is zero, the result is false.
fn is_divisible_by(lhs: u32, rhs: u32) -> bool {
    if rhs == 0 {
        return false;
    }
    lhs % rhs == 0
}

Die Inhalte werden als Markdown behandelt. Alle veröffentlichten Rust-BibliothekskÀsten (library crates) werden automatisch unter docs.rs mit rustdoc dokumentiert. Es ist idiomatisch, alle öffentlichen Elemente in einer API mithilfe dieses Musters zu dokumentieren.

To document an item from inside the item (such as inside a module), use //! or /*! .. */, called "inner doc comments":

//! This module contains functionality relating to divisibility of integers.
This slide should take about 5 minutes.