• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

【rust】rust安装,运行第一个Rust 程序 (1)

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

安装 Rust

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

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:


  /root/.cargo/bin


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


  /root/.profile
  /root/.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-unknown-linux-gnu
     default toolchain: stable
  modify PATH variable: yes


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

选择 1 ,回车继续;

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

Current installation options:

   default host triple: x86_64-unknown-linux-gnu
     default toolchain: stable
  modify PATH variable: yes

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

info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
334.4 KiB / 334.4 KiB (100 %) 191.0 KiB/s ETA:   0 s
info: latest update on 2019-05-14, rust version 1.34.2 (6c2484dc3 2019-05-13)
info: downloading component 'rustc'
 85.3 MiB /  85.3 MiB (100 %) 172.7 KiB/s ETA:   0 s       
info: downloading component 'rust-std'
 56.1 MiB /  56.1 MiB (100 %) 182.4 KiB/s ETA:   0 s       
info: downloading component 'cargo'
  4.3 MiB /   4.3 MiB (100 %) 188.8 KiB/s ETA:   0 s
info: downloading component 'rust-docs'
 10.2 MiB /  10.2 MiB (100 %) 169.4 KiB/s ETA:   0 s
info: installing component 'rustc'
 85.3 MiB /  85.3 MiB (100 %)  12.8 MiB/s ETA:   0 s
info: installing component 'rust-std'
 56.1 MiB /  56.1 MiB (100 %)  13.3 MiB/s ETA:   0 s
info: installing component 'cargo'
info: installing component 'rust-docs'
 10.2 MiB /  10.2 MiB (100 %)   1.2 MiB/s ETA:   0 s
info: default toolchain set to 'stable'

  stable installed - rustc 1.34.2 (6c2484dc3 2019-05-13)


Rust is installed now. Great!

To get started you need Cargo's bin directory ($HOME/.cargo/bin) in your PATH 
environment variable. Next time you log in this will be done automatically.

To configure your current shell run source $HOME/.cargo/env

如上显示代表安装完成;

 

 

rust卸载

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

 

 

 

第一个Rust程序

依据惯例,打印hello,world

编辑创建文件main.rs

fn main() {
    println!("Hello, world!");
}

 

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

rustc  main.rs

 

运行:

./main

 

输出:

Hello, world!

 

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Matlab基础刻意练习发布时间:2022-07-18
下一篇:
密度峰值聚类算法(DPC)密度峰值聚类算法MATLAB程序发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap