You've already forked comprehensive-rust
							
							
				mirror of
				https://github.com/google/comprehensive-rust.git
				synced 2025-10-31 08:37:45 +02:00 
			
		
		
		
	Add unittest example to rustdoc (#1276)
Fixes #1275 --------- Co-authored-by: Martin Geisler <martin@geisler.net>
This commit is contained in:
		| @@ -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> | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user