Rust学习笔记基础篇1--环境的搭建(霜之小刀)

Rust学习笔记基础篇1–环境的搭建(霜之小刀)

欢迎转载和引用,若有问题请联系
若有疑问,请联系
Email : [email protected]
QQ:2279557541


1 环境搭建

1.1 rust安装

这里我使用的是mac就以mac为例来说了,直接命令行运行(这条命令来自于rust的官网https://www.rust-lang.org

$ curl https://sh.rustup.rs -sSf | sh

运行结果如下

info: downloading installer

Welcome to Rust!

This will download and install the official compiler for the Rust programming 
language, and its package manager, Cargo.

It will add the cargo, rustc, rustup and other commands to Cargo's bin 
directory, located at:

  /Users/nanli/.cargo/bin

This path will then be added to your PATH environment variable by modifying the
profile files located at:

  /Users/nanli/.profile
  /Users/nanli/.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

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation

这里选择1就搞定了
由于网络原因可能要试很多次才能搞定,不过多试几次就没什么问题了

1.2 升级工具链与安装源码(用于ide的索引)

直接运行命令行即可

rustup self update
rustup update nightly
rustup component add rls --toolchain nightly
rustup component add rust-analysis --toolchain nightly
rustup component add rust-src --toolchain nightly

这里有可能速度非常慢,而且总是失败,我们的网络大家都懂的,这里有个办法,因为电子科大有个rust的镜像(感谢电子科大)我们在调用rustup前使用如下命令能够大大提高速度!

export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup

1.3 配置开发环境

我心目中的开发环境是集成开发环境,能编码,能运行,能开发。
所以这里我使用的是clion,另外vscode,sublime我都试过,都不让我调试。。。(哪位同学配置出来了能调试的环境,希望告知我下哈,万分感谢),所以我不得己选择了clion,而clion是要钱的,且。。。不便宜。。。好了,不能多说了。。。
装完后,在插件里直接搜索rust,然后就能创建,开发调试rust了。

猜你喜欢

转载自blog.csdn.net/lihn1987/article/details/79942256