Rust的 Cargo默认配置档:所有值

编程语言 2026-07-10

Rust Cargo有两个默认的配置文件,devrelease,在 The Cargo Book,章节 Profiles 中有描述。

不过,我不确定 The Cargo Book 是否解释了所有可能的配置选项。更重要的是,把所有设置拼凑起来有点繁琐。我更愿意直接查看原始的 .toml,无论它定义了哪些默认设置。

这些默认配置文件在Rust基金会的源码中定义在哪儿? 我想更清楚地理解有哪些可用的profile选项,并更简洁地查看它们的默认值。

解决方案

据 @kmdreko所说,答案就出现在所链接的页面上!😳

我认为 The Cargo Book中公布的值 仍然与 Cargo的源码 中定义的内容相匹配。

在此处重现

[profile.dev]
opt-level = 0
debug = true
split-debuginfo = '...'  # Platform-specific.
strip = "none"
debug-assertions = true
overflow-checks = true
lto = false
panic = 'unwind'
incremental = true
codegen-units = 256
rpath = false

[profile.release]
opt-level = 3
debug = false
split-debuginfo = '...'  # Platform-specific.
strip = "none"
debug-assertions = false
overflow-checks = false
lto = false
panic = 'unwind'
incremental = false
codegen-units = 16
rpath = false
站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。

相关文章