mirror of
https://github.com/google/comprehensive-rust.git
synced 2024-12-04 19:45:19 +02:00
commit
0324cd2b27
@ -3,7 +3,7 @@
|
|||||||
Rust has built-in support for documentation tests:
|
Rust has built-in support for documentation tests:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
/// Shorten string will trip the string to the given length.
|
/// Shortens a string to the given length.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use playground::shorten_string;
|
/// use playground::shorten_string;
|
||||||
@ -17,4 +17,4 @@ pub fn shorten_string(s: &str, length: usize) -> &str {
|
|||||||
|
|
||||||
* Code blocks in `///` comments are automatically seen as Rust code.
|
* Code blocks in `///` comments are automatically seen as Rust code.
|
||||||
* The code will be compiled and executed as part of `cargo test`.
|
* The code will be compiled and executed as part of `cargo test`.
|
||||||
* Test the above code on the [Rust Playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=c8ce535a3778218fed50c2b4c317d15d).
|
* Test the above code on the [Rust Playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=3ce2ad13ea1302f6572cb15cd96becf0).
|
||||||
|
Loading…
Reference in New Issue
Block a user