How about changing [lib] to [[lib]], to allow multiple library in a crate?

This was initially considered when designing cargo, but we chose to only allow one for a variety of reasons:

  • If there are two libraries, how do you select only one to build if you don’t want both?
  • Encouraging separate projects for each crate means dependencies are generally more re-usable than if they were bundled together. Crates which want to provide multiple libraries almost always end up getting large enough that they should be separated anyway as well.
  • With multiple libraries in one package there would need to be a method of specifying dependencies amongst them.
  • A number of features have been added after-the-fact which have made multiple libraries tricky. For example, if a package has a build script, how does it know which crate to link the native libraries into?

I think I may be forgetting some reasons as well, and @wycats may be able to add some in too.

10 Likes