Code examples from the documentation automatically become "documentation tests" to make sure your examples are still up to date when updating your code.
[1] https://doc.rust-lang.org/rustdoc/documentation-tests.html
#[cfg(doctest)]
#[macro_use]
extern crate doc_comment;
#[cfg(doctest)]
doctest!("../README.md");
Now, the readme examples are tested like everything else.https://github.com/rust-lang-nursery/lazy-static.rs/blob/mas...
An example of this in action: https://github.com/liskin/liscopridge/blame/68a656b7beb10a5c..., https://github.com/liskin/liscopridge/blob/68a656b7beb10a5cd...
Example: https://github.com/kstenerud/go-concise-encoding#library-usa...
Example: https://github.com/franciscop/server/blob/master/docs/docume...
I personally like at least one small example embedded in the README since it's zero effort, an example folder is great for _more_, but annoying to get started, what should I look at in the example folder first?
It’s one of those things that’s so easy to forget or not even think about but once you see it or think about it, it’s essential.
Nothing more frustrating than if you copy something from there but it turns out the README wasn't updated since the very first day and all the "hello world" code or install instructions are completely outdated
Maybe not include any code is the better solution, instead add an example folder.