Skip to content

Commit

Permalink
Update doctest in comments.md
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
chucksmash committed Jun 7, 2015
1 parent ae74652 commit 675b3de
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/doc/trpl/comments.md
Expand Up @@ -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
Expand Down

0 comments on commit 675b3de

Please sign in to comment.