Skip to content

Commit 554f595

Browse files
committed
Rollup merge of rust-lang#26073 - chuckSMASH:trpl-5-4-comments, r=steveklabnik
For a user following the path of reading Chapter 5: Syntax & Symantics prior to Chapter 4: Learn Rust, this will be the first time they have encountered executable tests inside documentation comments. The test will fail because the `add_one` function is not defined in the context of the doctest. This might not be the optimal place to introduce and explain the `/// #` notation but I think it is important that this snippet pass as a test when `rustdoc --test` is run against it.
2 parents a387078 + 675b3de commit 554f595

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/doc/trpl/comments.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ The other kind of comment is a doc comment. Doc comments use `///` instead of
2929
/// let five = 5;
3030
///
3131
/// assert_eq!(6, add_one(5));
32+
/// # fn add_one(x: i32) -> i32 {
33+
/// # x + 1
34+
/// # }
3235
/// ```
3336
fn add_one(x: i32) -> i32 {
3437
x + 1

0 commit comments

Comments
 (0)