rust编程世界
win winget install Rustlang.Rustup
ubuntu snap install rustup
rocky dnf install rust cargo
脚本 curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- 命令
rustc -V
版本rustup update
升级rustup self uninstall
卸载cargo -V
包管理rustup doc
本地文档rustup install 1.75.0
# 安装特定版本rustup default 1.75.0
# 设置为默认版本 - 镜像
使用国内镜像,在C:\Users\yoby.cargo\config.toml创建文件,文件名就是”config”,而不是”.config”!!![source.crates-io] replace-with = 'aliyun' [source.aliyun] registry = "sparse+https://mirrors.aliyun.com/crates.io-index/"
- vscode rls 和 Native Debug 两个扩展,演示
cargo new hello cd hello cargo build 生成 cargo build --release 正式版生成 cargo run cargo check 检测
- 最佳优化
[profile.release] opt-level = "z" 3是生成最小 lto = "fat" true链接优化但是编译短时间 strip = "symbols" true也可以
- 最佳优化
- hello world
fn greet_world() {
let southern_germany = "Grüß Gott!";
let chinese = "世界,你好";
let english = "World, hello";
let regions = [southern_germany, chinese, english];
for region in regions {
println!("{}", region);
}
}
fn main() {
greet_world();
}
- 常见库
cargo install slint-lsp
slint语言cargo install cargo-generate
ratatuicargo install rustlings
练习
作者:Yoby 创建时间:2020-07-25 00:08
最后编辑:Yoby 更新时间:2025-10-15 01:40
最后编辑:Yoby 更新时间:2025-10-15 01:40