Cargo can be configured by adding a file in .cargo/config.toml.

Notable settings

[lib]
crate-type = [...]

crate-type defines what kind of library or binary the Rust compiler should generate when building the crate.

Options include:

crate-type optionsDescription
binAn executable is produces from main.rs
libAn alias for “compiler recommended” library (one of the options below), generated from lib.rs
dylibDynamic Rust library. (.so on Linux, .dylib on Mac, and .dll on Windows)
staticlibA static system library that will not be linked to other libraries. (.a on most filesystems, .lib on Windows MSVC). Recommended when linking Rust code to a non-Rust application
cydlibC-compatible dynamic library, to load the binary from another language. Strips most Rust-specific metadata for consumption by non-Rust application
rlibA “Rust lbrary” that can be interpreted by the compiler for future linkage. Also an intermediate artifact in generating a staticlib
proc-macroUsed to export procedural macros. Compiles to the same target as the compiler used, and not for the target program.

Can be stacked.