i have a file structure:
i want to use
cargoworkspace, and tried doing this in
path = "../function"
but this did not work. may i know how i can go about using a single source file in a cargo workspace? thank you!
You can't depend on a single file. You can only depend on cargo packages which have a
If you want a "single file crate" you do something like this:
name = "function"
version = "0.1.0"
edition = "2021"
path = "function.rs"
With a file layout like this:
├── Cargo.toml // add a path dependency here to your "function" crate
│ ├── Cargo.toml // the config above
│ └── function.rs
why not just try
in your main.rs?
how about a soft link?
BTW why do you want to use a single file rather than cargo workspace?
because it is a very small function that i feel has no need to come with a
src directory and a
.git directory. however, it can be shared across multiple projects.
i tried this, but it didn't work. what worked for me was this:
#[path = "../../function.rs"]
upon further testing, @erelde 's answer also works.