Avatar ·

How to create a package in Rust that contains both a library (lib) and an executable (bin)?

Hi everyone! I just started learning Rust and am trying to understand project organization. I have a task: I want to write a small utility for working with CSV files. But at the same time, I want the core logic (parsing, filtering) to be reusable in other projects as a library. Currently my project looks like this: ``` my_project/ ├── Cargo.toml ├── src/ │ └── main.rs ``` In `main.rs`, I wrote both parsing and output of results. This is inconvenient: if I want to use the same parser in another project, I'll have to copy the code. I read that in Rust you can make a package that contains both `lib.rs` (library) and `main.rs` (binary). But I don't understand how to configure it properly. In `Cargo.toml`, I don't see explicit instructions. How does Cargo know that I have two target files? I