文档

Rust comes with extensive documentation. For example:

事实上,您可以为自己的代码编写文档:

/// 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
}

The contents are treated as Markdown. All published Rust library crates are automatically documented at docs.rs using the rustdoc tool. It is idiomatic to document all public items in an API using this pattern.

如需从项内(例如在模块内)为项编写文档,请使用 //!/*! .. */,这称为“内部文档注释”:

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