Rust在Debian中的依赖管理
一 工具链与环境准备
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shrustup updaterustup default stablesudo apt update && sudo apt install rustc cargorustup component add clippy rustfmt,用于代码检查与格式化。二 项目内依赖管理 Cargo
cargo new my_project && cd my_project[dependencies]
rand = "0.8"
serde = { version = "1.0", features = ["derive"] }
cargo add some_crate(添加最新版);cargo add serde --features derive(带特性)cargo updatecargo build、cargo run、cargo test三 与Debian系统库交互
cargo install bindgenbindgen /path/to/header.h -o src/lib.rs四 进阶与最佳实践
rustup component add clippy rustfmtcargo clippy、cargo fmtcargo build/test 保证一致性。