Rust入门-mac下安装及idea开发环境搭建

一、安装

rust安装部署相对简单,我们可以直接参考官网安装

  • curl https://sh.rustup.rs -sSf | sh
  • source $HOME/.cargo/env
  • rustc --version如果显示版本号、提交的 hash 值和提交时间,恭喜你!则 Rust 已成功安装!
  • cargo --version如果你看到了版本号,一切 OK!

二、idea开发环境搭建

  • 创建项目cargo new hello_world --bin这个命令传递了--bin参数因为我们的目标是直接创建一个可执行程序,而不是一个库。
  • Rust入门-mac下安装及idea开发环境搭建|百赚网
  • 导入到IDE,这里选的是IntelliJ,先安装rust插件,双击shift键,输入plugin
  • 选中之后搜索安装就好了,重启IDE,用IDE打开Project,找到main.rs,直接右键运行,如果看到missing xcrun at:XXXXX说明你的mac缺少命令行工具,可以选择安装命令行工具或者xcode,下载地址,登陆后下载
  • 卸载命令:rustup self uninstall,在安装时有提示该命令

三、环境测试

1.idea打开新建项目hello_word

Rust入门-mac下安装及idea开发环境搭建|百赚网

2.打印相关输出

/Users/zhangpeng/.cargo/bin/cargo run --color=always --package hello_world --bin hello_world
Compiling hello_world v0.1.0 (/data/project/hello_world)
Finished dev [unoptimized + debuginfo] target(s) in 0.33s
Running `/data/project/hello_world/target/debug/hello_world`
Hello, Arvin, http://www.chinad.top 欢迎你 !
Hello, world!

Process finished with exit code 0

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章