Compiling multiple files separately

Hey there, I'm really satisfied with Rust + Cargo, but I need some help. I need to compile multiple files seperately, example and, both seperately but I don't know how to, normally I would do with rustc but I have configs on Cargo.toml.

TL;DR if I'm saying right I need to output multiple products from a single Cargo.toml.

If you put them in src/bin/ and src/bin/, then cargo will compile it into two different binaries, each with its own main function.

To share code between them, define a src/ and put the shared code either in that file or in sub-modules of When you are in the and files, you will need use your_package_name::* to import the shared code.



This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.