23.10 Binary vs. Library Crates

  • Binary crates compile into executables, typically containing a main.rs with a fn main() entry point.
  • Library crates produce reusable functionality with a lib.rs, without generating an executable by default.

You can combine both by specifying [lib] and [bin] sections in Cargo.toml. This approach is handy for projects that expose a library API as well as a command-line interface.