I have a package with an examples
directory, which in turn houses a "crate-type" example (as opposed to a file).
.
├── Cargo.toml
├── examples
│ └── my_example
│ ├── Cargo.toml
│ └── src
│ └── main.rs
└── src
└── lib.rs
Trying to run this with cargo run --example my_example
yields an error:
error: no example target named `my_example`
If I move main.rs
out of src
and up into my_example
, Cargo can find it, but it appears to ignore the Cargo.toml
.
I know the dev-dependencies
from the top-level package will be automatically linked, but if possible, I think I'd rather list them inside the example's Cargo.toml
. axum
does this, but axum
is a workspace and declares every crate inside examples
as its own package. I'm not using Cargo Workspaces, so I can't copy that.