All I receive is this very weird error, it seems the Rust compiler doesn't expect text inside that doc attribute:
---- src/lib.rs - HumanCount::human_count (line 41) stdout ----
error: unknown start of token: `
--> src/lib.rs:42:1
|
4 | ```
| ^^^
|
= note: character appears 2 more times
help: Unicode character '`' (Grave Accent) looks like ''' (Single Quote), but it is not
|
4 | '''
|
error: unknown start of token: `
--> src/lib.rs:45:1
|
7 | ```
| ^^^
|
= note: character appears 2 more times
help: Unicode character '`' (Grave Accent) looks like ''' (Single Quote), but it is not
|
7 | '''
|
error: aborting due to 2 previous errors
Couldn't compile the test.
Another curious detail, the doc is simply ignored if I remove that blank line, the Rust compiler doesn't find it anymore. But I do want that blank line anyway, so it skips one line between the explanation and the example.
Doc comments are parsed as Markdown. Markdown has two ways to make a code block: ```, or four spaces of indentation. Your string literal has four spaces of indentation in the relevant lines, so the ``` are being taken as part of the code block.
To fix this, you can do one of these:
Remove the indentation.
Don't use raw string literals, and then put an explicit newline and line continuation at the end of each line: \n\. This has the effect of discarding the whitespace at the beginning of the next line. However, this will also discard any wanted indentation.
Use indoc!, which will strip a uniform amount of whitespace from all lines in the literal.
Option 1 did work, but is ugly as hell.
I'm trying the second one before including another dev-dependency, but with the above, it simply finds 12 tests instead of 13...
Oh, you are using a raw string literal r#, so the backslashes are taken literally. You will have to use a non-raw literal, or one of the other two options I suggested.