用途:面向单 crate 的 Cargo 项目,指导脚手架搭建、Cargo.toml 编写、依赖声明、特性设计、profile 调优、源码覆盖与 lint 与 MSRV 配置。
主要能力:覆盖 cargo new/init 与 lib/bin 选择、[package]/[dependencies]/[dev-dependencies]/[build-dependencies] 分区、语义化版本要求(caret/tilde/exact/通配)、features 加法原则与 dep:/? 语法、[profile.*] 编译选项(LTO、opt-level、codegen-units、strip、panic)、[patch]/[replace] 覆盖、[lints] 表及 Rust 1.84+ MSRV 感知解析器。
使用方式:新建目录用 cargo new;初始化当前目录用 cargo init;库优先时加 --lib;添加依赖如 cargo add tokio --no-default-features --features rt,macros,sync,开发依赖 cargo add --dev proptest,可选依赖 cargo add serde --optional --features derive。可用 cargo hack check --feature-powerset --no-dev-deps 测试特性组合。
适用场景:搭建或维护单 crate 项目、编辑 Cargo.toml、设计加法特性、调优发布 profile、调试期用 [patch.crates-io] 覆盖依赖、统一 lint、按 MSRV 选版本。多 crate 工作区参见 rust-impl-workspaces,build.rs 参见 rust-impl-build-scripts。
限制:具体版本行为与新增语法以官方 Cargo 文档为准;[patch] 不应出现在已发布 crate 中;panic="abort" 需先确认无依赖使用 catch_unwind;forbid 不可被内部属性覆盖。部分参考文件(methods/examples/anti-patterns)内容未提供细节。