How do you run examples for cargo crates
(most crates have /examples
)
How to do it
- Add
[[example]]
section incargo.toml
- Specify id and path
[[example]]
name = "first"
path = "examples/simple.rs"
- Run it with
cargo run --example first
Victory!
More reading
https://users.rust-lang.org/t/run-examples-in-subfolders-using-cargo/18154/3