-
curl https://sh.rustup.rs -sSf | sh -
source $HOME/.cargo/env -
rustc --version如果显示版本号、提交的 hash 值和提交时间,恭喜你!则 Rust 已成功安装! -
cargo --version如果你看到了版本号,一切 OK! -
其他安装信息
Welcome to Rust! This will download and install the official compiler for the Rust programming language, and its package manager, Cargo. # cargo, rustc, rustup 和其他工具会被放到~/.cargo/bin目录下 It will add the cargo, rustc, rustup and other commands to Cargo's bin directory, located at: /Users/micocube/.cargo/bin # 同时会修改bash的profile文件 This path will then be added to your PATH environment variable by modifying the profile files located at: /Users/micocube/.profile /Users/micocube/.bash_profile You can uninstall at any time with rustup self uninstall and these changes will be reverted. Current installation options: default host triple: x86_64-apple-darwin default toolchain: stable modify PATH variable: yes -
创建项目
cargo new hello_world --bin这个命令传递了--bin参数因为我们的目标是直接创建一个可执行程序,而不是一个库。 -
导入到IDE,这里选的是IntelliJ,先安装rust插件,双击
shift键,输入plugin -
image.png
-
image.png
选中之后搜索安装就好了,重启IDE,用IDE打开Project,找到main.rs,直接右键运行,如果看到missing xcrun at:XXXXX说明你的mac缺少命令行工具,可以选择安装命令行工具或者xcode,下载地址,登陆后下载 -
卸载命令:
rustup self uninstall,在安装时有提示该命令












网友评论