Why can a Cargo package only have one library target?

后端 未结 2 1144
旧时难觅i
旧时难觅i 2020-12-11 15:20

According to its manual, Cargo packages can have multiple executable targets, but only one library target is allowed.

A package can contain zero or o

2条回答
  •  粉色の甜心
    2020-12-11 16:03

    I would expect that it is because a library crate within a package is already a collection (functions, types, values, etc.) whereas the binary crates are opaque executables (with a main entry point). Consequently, the library crates name is merely the root module within its hierarchy and the binary crates name is its entirety and occur at the top level of the package.

提交回复
热议问题