1、安装
在 Linux 或 macOS 上安装 rustup
打开终端并输入下面命令:
$ curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh
如果安装成功,将出现下面这行:
Rust is installed now. Great!
2、更新
$ rustup self uninstall
3、卸载
$ rustup self uninstall
4、检查安装是否成功
$ rustc -V
rustc 1.56.1 (59eed8a2a 2021-11-01)$ cargo -V
cargo 1.57.0 (b2e52d7ca 2021-10-21)
5、创建和运行第一个程序 Hello World
(1)创建一个新项目,cargo是Rust的包管理工具
$ cargo new world_hello
$ cd world_hello
(2)运行项目
(base) guilinhuang@GuilindeMacBook-Pro world_hello % cargo run Compiling world_hello v0.1.0 (/Users/guilinhuang/Desktop/RustProject/world_hello)Finished dev [unoptimized + debuginfo] target(s) in 0.83sRunning `target/debug/world_hello`
Hello, world!
看到Hello world!就大功告成啦
千里之行,始于足下,加油!