Cargo build: dependencies in release, current crate in debug

I do not know if cargo build already does this by default, but is it possible to:

build all dependencies in ‘release’ (optimized) mode
but build the current crate in ‘debug’ mode?

Yo, recently this has been made possible on nightly! :tada:
TL;DR from cargo documentation:

# Cargo.toml
cargo-features = ["profile-overrides"]

# All dependencies (but not this crate itself or any workspace member)
# will be compiled with -Copt-level=2 . This includes build dependencies.
[profile.dev.overrides."*"]
opt-level = 2
3 Likes

profile.dev.overrides + opt-level is precisely what I was looking for.

Thanks!