DEV Community

Discussion on: What's up, doc? Rust doctests and you

Collapse
 
jeikabu profile image
jeikabu • Edited

Good write up on Rust fundamentals.
I have a love-hate relationship with the current state.

I do love the idea of testing documentation examples.

I'm less than thrilled about some of the current tooling:

  • With VSCode and RLS, at least, no syntax highlighting and no Intellisense
  • Using ?/Result is clumsy
  • compile_fail is useful to show correct ownership usage, but since you can't specify the failure type unrelated failures also cause the test to pass
  • IIRC, test failures aren't helpful; think it mentions the line number in the test instead of the line in the file, and maybe doesn't have the filename

There's other comment formats that can be helpful. For example, to write a multi-line module doc test:

/*!
## Tests here
*/