Hacker News new | ask | show | jobs
by returningfory2 458 days ago
Rust has this, and it just makes so much sense. Especially when you write a library in which the basic demo is also the basic unit test you want to make. Instead of writing a specific unit test that's hidden in source code, you just embed it in the docs and then you (a) don't have code duplication and (b) have verification your documentation's code samples are actually correct.
1 comments

> and (b) have verification your documentation's code samples are actually correct.

I find a lot of libraries don't go through the effort to actually use doctests, and just stick `no_run` everywhere, which defeats a lot of the purpose.