Rust: 如何在windows环境中用Atom中玩转它?--new

玩转它,首先要能在atom中能把rust代码走下来。
今天,主要讲一下第一次在atom中如何把rust代码走起来。原来写过一篇,但有点老,rust本身也有变化,所以重新更新一下。也供自己折腾使用吧。

一、windows中的几个前提
(1)准备好atom
这个我就不说了,不清楚的,找官网。下载并安装。

(2)看看是否装了MSYS2

https://github.com/rust-lang/rust

There are two prominent ABIs in use on Windows: the native (MSVC) ABI used by Visual Studio, and the GNU ABI used by the GCC toolchain. Which version of Rust you need depends largely on what C/C++ libraries you want to interoperate with: for interop with software produced by Visual Studio use the MSVC build of Rust; for interop with GNU software built using the MinGW/MSYS2 toolchain use the GNU build.

(3)rust的安装
找到rust官网:
https://www.rust-lang.org/en-US/
这里写图片描述

看到么,安装rust.

但是,有一个检查,需要注意:

是否安装了Microsoft Visual C++ Build Tools 2017。

On Windows, Rust additionally requires the C++ build tools for Visual Studio 2013 or later. The easiest way to acquire the build tools is by installing Microsoft Visual C++ Build Tools 2017 which provides just the Visual C++ build tools. Alternately, you can install Visual Studio 2017, Visual Studio 2015, or Visual Studio 2013 and during install select the "C++ tools".

建议下载vs2017或vs2015
这里写图片描述

下载完了后,再运行rustup-init.exe.

这个过程可能很长。短则半小时,长则一二个小时不等。

这个过程装好后,你可以看到cargo,rustc,rustup三个重要的文件在其中。但racer现是不在其中的。
这里写图片描述

这步如果没有成功,后面就会出现很大的问题。

二、在cargo中安装 racer
这一步是必须的。

C:\>cargo install racer

完成这步,上面的racer.exe文件才会出现在.cargo\bin\下面。

如果这步不成功,后面racer.exe的路径就无法填写了。

三、转到Atom
需要说明的是:
Atom中最重必要的两个库是build、cargo build(出现cargo:build 标识的唯一决定因素)。
另外一个就是language-rust。这个和cargo build需要一起配合。

而:其他如racer、rustfmt、linter-rust是可有可无的。

(1)建议在atom中下载

这里写图片描述

这里写图片描述

(2)在cargo build中进行配置

在atom 中的cargo build:
这里写图片描述
同样,在racer中配置,其中有一栏很清楚:(这一步不是必须的)
这里写图片描述

下面有一个源代码的目录。

这个可以到这儿下载,并解压,找到src的目录:

这里写图片描述

装好后,重启。

如果你看到左下面的出现了cargo:run(release)图标(这个地方点击后,你就知道如何运行rust代码了)时,证明ok了。

这里写图片描述

如果你不喜欢,可以下了它:

 rustup self uninstall

另外,以下两个库推荐:

这里写图片描述

这里写图片描述

关于如何装上rustfmt,可以参见2017年2月份的博客文章:

Rust: 如何在Atom中用上Atom Beautify(绑定rustfmt)?

简单地说,需要在cargo 中安装,在atom中下载。

祝你使用愉快。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值