23.10 Binary vs. Library Crates
- Binary crates compile into executables, typically featuring a
main.rs
with afn main()
entry point. - Library crates produce reusable functionality via a
lib.rs
and do not generate an executable by default.
You can combine both by specifying [lib]
and [bin]
sections in Cargo.toml
, letting you expose a library API and also provide a command-line interface.