安装 Rust

在 Unix 类系统如 Linux 和 macOS 上,打开终端并输入:

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

回车后安装过程出现如下显示:

  1. info: downloading installer
  2.  
  3. Welcome to Rust!
  4.  
  5. This will download and install the official compiler for the Rust programming
  6. language, and its package manager, Cargo.
  7.  
  8. It will add the cargo, rustc, rustup and other commands to Cargo's bin
  9. directory, located at:
  10.  
  11. /root/.cargo/bin
  12.  
  13. This path will then be added to your PATH environment variable by modifying the
  14. profile files located at:
  15.  
  16. /root/.profile
  17. /root/.bash_profile
  18.  
  19. You can uninstall at any time with rustup self uninstall and these changes will
  20. be reverted.
  21.  
  22. Current installation options:
  23.  
  24. default host triple: x86_64-unknown-linux-gnu
  25. default toolchain: stable
  26. modify PATH variable: yes
  27.  
  28. ) Proceed with installation (default)
  29. ) Customize installation
  30. ) Cancel installation

选择 1 ,回车继续;

这样会下载一个脚本并开始安装。如果一切顺利,你将会看到:

  1. Current installation options:
  2.  
  3. default host triple: x86_64-unknown-linux-gnu
  4. default toolchain: stable
  5. modify PATH variable: yes
  6.  
  7. ) Proceed with installation (default)
  8. ) Customize installation
  9. ) Cancel installation
  10. >
  11.  
  12. info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
  13. 334.4 KiB / 334.4 KiB ( %) 191.0 KiB/s ETA: s
  14. info: latest update on --, rust version 1.34. (6c2484dc3 --)
  15. info: downloading component 'rustc'
  16. 85.3 MiB / 85.3 MiB ( %) 172.7 KiB/s ETA: s
  17. info: downloading component 'rust-std'
  18. 56.1 MiB / 56.1 MiB ( %) 182.4 KiB/s ETA: s
  19. info: downloading component 'cargo'
  20. 4.3 MiB / 4.3 MiB ( %) 188.8 KiB/s ETA: s
  21. info: downloading component 'rust-docs'
  22. 10.2 MiB / 10.2 MiB ( %) 169.4 KiB/s ETA: s
  23. info: installing component 'rustc'
  24. 85.3 MiB / 85.3 MiB ( %) 12.8 MiB/s ETA: s
  25. info: installing component 'rust-std'
  26. 56.1 MiB / 56.1 MiB ( %) 13.3 MiB/s ETA: s
  27. info: installing component 'cargo'
  28. info: installing component 'rust-docs'
  29. 10.2 MiB / 10.2 MiB ( %) 1.2 MiB/s ETA: s
  30. info: default toolchain set to 'stable'
  31.  
  32. stable installed - rustc 1.34. (6c2484dc3 --)
  33.  
  34. Rust is installed now. Great!
  35.  
  36. To get started you need Cargo's bin directory ($HOME/.cargo/bin) in your PATH
  37. environment variable. Next time you log in this will be done automatically.
  38.  
  39. To configure your current shell run source $HOME/.cargo/env

如上显示代表安装完成;

rust卸载

卸载 Rust 跟安装它一样容易:
  1. rustup self uninstall

第一个Rust程序

依据惯例,打印hello,world

编辑创建文件main.rs

  1. fn main() {
  2. println!("Hello, world!");
  3. }

编译(类似于C语言的gcc编译):

  1. rustc main.rs

运行:

  1. ./main

输出:

  1. Hello, world!

【rust】rust安装,运行第一个Rust 程序 (1)的更多相关文章

  1. 运行第一个Hadoop程序,WordCount

    系统: Ubuntu14.04 Hadoop版本: 2.7.2 参照http://www.cnblogs.com/taichu/p/5264185.html中的分享,来学习运行第一个hadoop程序. ...

  2. Spark认识&环境搭建&运行第一个Spark程序

    摘要:Spark作为新一代大数据计算引擎,因为内存计算的特性,具有比hadoop更快的计算速度.这里总结下对Spark的认识.虚拟机Spark安装.Spark开发环境搭建及编写第一个scala程序.运 ...

  3. 运行第一个ruby程序

    0x00 安装 首先需要安装一个ruby的环境,ruby分为win.linux.macOS版本.不用系统安装方法略有差异,不在这进行讲解. 0x01 运行第一个ruby程序 我这里是win环境,打开命 ...

  4. 运行第一个python程序,python 变量,常量,注释

    一.运行第一个python程序: print('Hello,world') 保存为.py文件 在cmd窗口: python3x:python  py文件路径 回车 python2x:python  p ...

  5. OpenCV学习笔记(一)安装及运行第一个OpenCV程序

    1.下载及安装 OpenCV是一套开源免费的图形库,主要有C/C++语言编写,官网: http://opencv.org/ .在 http://opencv.org/downloads.html 可以 ...

  6. 使用Eclipse运行第一个Go程序

    Windows 10家庭中文版,go version go1.11 windows/amd64, Eclipse IDE for C/C++ Developers Photon Release (4. ...

  7. [IOS]从零开始搭建基于Xcode7的IOS开发环境和免开发者帐号真机调试运行第一个IOS程序HelloWorld

    首先这篇文章比较长,若想了解Xcode7的免开发者帐号真机调试运行IOS程序的话,直接转到第五部分. 转载请注明原文地址:http://www.cnblogs.com/litou/p/4843772. ...

  8. 编译运行第一个Java程序——通过示例学习Java编程3

    作者:CHAITANYA SINGH 来源:https://www.koofun.com//pro/kfpostsdetail?kfpostsid=13 在本教程中,我们将了解如何编写.编译和运行Ja ...

  9. python基础(2):python的安装、第一个python程序

    1. 第一个python程序 1.1 python的安装 自己百度,这是自学最基本的,安装一路确定即可,记得path下打钩. 1.2 python的编写 python程序有两种编写方式: 1.进入cm ...

随机推荐

  1. 转:【开源必备】常用git命令

    原文:https://zhuanlan.zhihu.com/p/25868120 [开源必备]常用git命令 [已重置]   如今在技术领域,码农们习惯了开源,也离不开免费开源的代码,轻松获取代码,不 ...

  2. react-native的技巧

    按钮定制 給图片添加点击事件 <TouchableOpacity onPress={this.lookAlbum} style={{flex: 0, height: 40, width: 40, ...

  3. CAS单点登录系统入门--分布式登录验证

    1.开源单点登录系统CAS入门 1.1 什么是单点登录 单点登录(Single Sign On),简称为 SSO,是目前比较流行的企业业务整合的解决方案之一.SSO的定义是在多个应用系统中,用户只需要 ...

  4. Kinect V2入门之数据获取步骤

    在Kinect for windows SDK2.0中,获取并处理数据源接口步骤如下: Sensor -> Source -> Reader -> Frame -> Data ...

  5. PHP数据结构基本概念

    原文:https://www.cnblogs.com/crystaltu/p/6408484.html 学习任何一种技术都应该先清楚它的基本概念,这是学习任何知识的起点!本文是讲述数据结构的基本概念, ...

  6. while循环和字符串格式化

    小知识点 \n#换行 \t #制表 \r #回车 print(a,b,c,d,sep="\n")换行 sep默认空格 1.while--关键字(死循环) while 空格 条件: ...

  7. 吴恩达机器学习7:代价函数(Cost function)

    一.简介 1.在线性回归中,我们有一个这样的训练集,M代表训练样本的数量,假设函数即用来进行预测的函数是这样的线性函数的形式,我们接下来看看怎么选择这两个参数: 2.如下图中,怎么选择两个参数来更好的 ...

  8. 伟大的GIL

    GIL 首先需要明确的一点是GIL并不是Python的特性,它是在实现Python解析器(CPython)时所引入的一个概念.就好比C++是一套语言(语法)标准,但是可以用不同的编译器来编译成可执行代 ...

  9. 3Linux - 常用 Linux 命令的基本使用

    常用 Linux 命令的基本使用 转自 目标 理解学习 Linux 终端命令的原因 常用 Linux 命令体验 01. 学习 Linux 终端命令的原因 Linux 刚面世时并没有图形界面,所有的操作 ...

  10. 1130. Infix Expression (25)

    Given a syntax tree (binary), you are supposed to output the corresponding infix expression, with pa ...