From 675b3decadc149b400d9afc4c59e0703a0b100ff Mon Sep 17 00:00:00 2001 From: Chuck Bassett Date: Sun, 7 Jun 2015 15:06:58 -0400 Subject: [PATCH] Update doctest in comments.md 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 if it is going to be shown. --- src/doc/trpl/comments.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/doc/trpl/comments.md b/src/doc/trpl/comments.md index fa27d1c226cc4..7687d2a57da92 100644 --- a/src/doc/trpl/comments.md +++ b/src/doc/trpl/comments.md @@ -29,6 +29,9 @@ The other kind of comment is a doc comment. Doc comments use `///` instead of /// let five = 5; /// /// assert_eq!(6, add_one(5)); +/// # fn add_one(x: i32) -> i32 { +/// # x + 1 +/// # } /// ``` fn add_one(x: i32) -> i32 { x + 1