I am a bit confused by the existence of the three upper levels in the Rust module hierarchy and why they are all needed. If I understand it correctly:
- Crates are simple projects that contain multiple modules and each crate is either a library or a binary.
- Packages contain one or more crates with a maximum of one library.
- Workspaces are a group of packages.
I understand the need to keep several crates together if they are being developed together, so either packages or workspaces make sense to me, but I don't get why both need to exist and why there would need to be a maximum of 1 library restriction on packages. What are the advantages of doing it this way?
I have read Why can a Cargo package only have one library target? that gives an explanation for the 1 library crate per package rule, but it made me more confused, because you can still have packages with binaries and even "worse" no libraries. If packages are meant to be an abstraction for Cargo, the package manager, why allow binaries in them at all? Why allow packages without a single library inside? Can you import a no-library-package as a dependency?