mirror of
https://github.com/google/comprehensive-rust.git
synced 2024-12-15 06:20:32 +02:00
Add unittest example to rustdoc (#1276)
Fixes #1275 --------- Co-authored-by: Martin Geisler <martin@geisler.net>
This commit is contained in:
parent
1c43db108b
commit
c894ea3517
@ -6,6 +6,11 @@ All language items in Rust can be documented using special `///` syntax.
|
||||
/// Determine whether the first argument is divisible by the second argument.
|
||||
///
|
||||
/// If the second argument is zero, the result is false.
|
||||
///
|
||||
/// # Example
|
||||
/// ```
|
||||
/// assert!(is_divisible_by(42, 2));
|
||||
/// ```
|
||||
fn is_divisible_by(lhs: u32, rhs: u32) -> bool {
|
||||
if rhs == 0 {
|
||||
return false; // Corner case, early return
|
||||
@ -18,6 +23,7 @@ The contents are treated as Markdown. All published Rust library crates are
|
||||
automatically documented at [`docs.rs`](https://docs.rs) using the
|
||||
[rustdoc](https://doc.rust-lang.org/rustdoc/what-is-rustdoc.html) tool. It is
|
||||
idiomatic to document all public items in an API using this pattern.
|
||||
Code snippets can document usage and will be used as unit tests.
|
||||
|
||||
<details>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user