cargo

Build scripts (build.rs) for compile-time code generation

A build.rs file runs before compiling your crate, enabling code generation, FFI binding generation, or environment checks. I use build scripts to generate Rust code from proto files (with prost), compile C libraries, or set cfg flags based on the targ

Feature flags for conditional compilation

Cargo's feature flags let you enable or disable parts of your crate at compile time. I use them for optional dependencies (like serde), platform-specific code, or different build profiles. Features are defined in Cargo.toml and checked with #[cfg(feat

Cargo workspaces for multi-crate projects

For larger projects, I organize code into multiple crates within a Cargo workspace. The root Cargo.toml lists workspace members, and each crate has its own dependencies and Cargo.toml. This lets you split code into libraries and binaries, share code b

Cargo.lock for reproducible builds

Cargo generates Cargo.lock to pin exact dependency versions. For binaries, commit the lock file so everyone builds the same dependencies. For libraries, don't commit it (users should resolve their own). The lock file enables reproducible builds: cargo