Multi-file examples

Minimum Rust version: 1.22

Cargo has an examples feature for showing people how to use your package.By putting individual files inside of the top-level examples directory, youcan create multiple examples.

But what if your example is too big for a single file? Cargo supports addingsub-directories inside of examples, and looks for a main.rs inside ofthem to build the example. It looks like this:

  1. my-package
  2. └──src
  3. └── lib.rs // code here
  4. └──examples
  5. └── simple-example.rs // a single-file example
  6. └── complex-example
  7. └── helper.rs
  8. └── main.rs // a more complex example that also uses `helper` as a submodule