Rust cargo常用命令

四 19 十一月 2026

Rust cargo常用命令

cd ~/.cargo
# 创建config文件
vim config
# 添加如下镜像源
[source.crates-io]
replace-with = 'rsproxy-sparse'
[source.rsproxy]
registry = "https://rsproxy.cn/crates.io-index"
[source.rsproxy-sparse]
registry = "sparse+https://rsproxy.cn/index/"
[registries.rsproxy]
index = "https://rsproxy.cn/crates.io-index"
[net]
git-fetch-with-cli = true

创建新项目

cargo new my_project

构建项目

cargo build

运行项目

cargo run

检查项目,但不构建可执行文件

cargo check

运行项目的测试

cargo test

发布项目

cargo build --release

更新依赖

cargo update

查看项目依赖关系树

cargo tree

创建新的库项目

cargo new --lib my_library

文档生成

cargo doc

Category: 编程rust


减少rust编译后程序体积

四 19 十一月 2026

编译release版本

cargo build --release

strip 命令

strip -s target/release/testGui

优化等级

通过修改默认优化等级方式减少体积,以cpu换空间,如果不是必要,建议不要改

在Cargo.toml中新增下面配置 …

Category: 编程rust

Read More

Rust actix-web框架

二 23 九月 2025

Github

https://github.com/actix/actix-web 官方文档 https://actix.rs/docs/getting-started

设置国内镜像 cd ~/.cargo

创建config文件

vim config

添加如下镜像源

[source.crates-io] replace-with = 'rsproxy-sparse' [source.rsproxy] registry = "https://rsproxy.cn/crates.io-index" [source.rsproxy-sparse] registry …

Category: 编程rust

Read More

Rust Druid桌面应用框架

二 23 九月 2025

Github https://github.com/linebender/druid 管方文档 https://docs.rs/druid/latest/druid/

简介 Druid 是一个用于构建现代、高性能、跨平台桌面应用的 Rust 库。以下是一些 Druid 框架的 …

Category: 编程rust

Read More

Rust安装及学习资料

二 23 九月 2025

Rust安装及学习资料 目录 官网 包管理 Rust 程序设计语言 通过例子学 Rust 在线运行 安装rustup 升级Rust 卸载Rust 创建项目 官网 https://www.rust-lang.org/zh-CN/ 包管理 https://crates …

Category: 编程rust

Read More

从字符串来浅谈Rust内存模型

四 28 一月 2021

最近我尝试在课设程序中引入了Rust,理由很简单——Rust是我心目中不可多得的在语言层面尝试改进内存安全与高性能的现代编程语言。不过这种尝试确实相当前卫,以至于让Rust对初学者显得不是那么友好。在这篇文章中,我将尝试通过 …

Category: 编程rust

Read More
Page 1 of 1