日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

rust安装教程linux,如何在 Linux 中安装 Rust 编程语言

發布時間:2024/4/17 linux 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 rust安装教程linux,如何在 Linux 中安装 Rust 编程语言 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Rust 通常被稱為 rust-lang。Rust 是一個由 Mozilla Research 贊助的通用的、多范式、現代的、跨平臺和開源系統編程語言。

它旨在實現安全性、速度和并發性等目標。

Rust 在語法上與 C++ 相似,但它的設計者希望它在保持性能的同時提供更好的內存安全性。

Rust 目前在許多組織中使用,例如 Firefox、Chef、Dropbox、Oracle、GNOME 等。

如何在 Linux 中安裝 Rust 語言?

我們可以通過多種方式安裝 Rust,但以下是官方推薦的安裝方式。

$ 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:

/home/linuxidc/.cargo/bin

This path will then be added to your PATH environment variable by modifying the

profile files located at:

/home/linuxidc/.profile

/home/linuxidc/.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

info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'

info: latest update on 2018-12-06, rust version 1.31.0 (abe02cefd 2018-12-04)

info: downloading component 'rustc'

77.7 MiB / 77.7 MiB (100 %) 1.2 MiB/s ETA: 0 s

info: downloading component 'rust-std'

54.2 MiB / 54.2 MiB (100 %) 1.2 MiB/s ETA: 0 s

info: downloading component 'cargo'

4.7 MiB / 4.7 MiB (100 %) 1.2 MiB/s ETA: 0 s

info: downloading component 'rust-docs'

8.5 MiB / 8.5 MiB (100 %) 1.2 MiB/s ETA: 0 s

info: installing component 'rustc'

info: installing component 'rust-std'

info: installing component 'cargo'

info: installing component 'rust-docs'

info: default toolchain set to 'stable'

stable installed - rustc 1.31.0 (abe02cefd 2018-12-04)

Rust is installed now. Great!

To get started you need Cargo's bin directory ($HOME/.cargo/bin)in your PATH

environment variable.Nexttime you log inthis will be done automatically.

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

運行以下命令配置當前 shell。

$ source $HOME/.cargo/env

運行以下命令驗證已安裝的 Rust 版本。

$ rustc --version

rustc 1.31.0(abe02cefd 2018-12-04)

如何測試 Rust 編程語言?

安裝 Rust 后,請按照以下步驟檢查 Rust 語言是否正常工作。

$ mkdir~/projects

$ cd~/projects

$ mkdir hello_world

$ cd hello_world

創建一個文件并添加以下代碼并保存。確保 Rust 文件始終以 .rs 擴展名結尾。

$ vi2g.rs

fn main(){

println!("Hello, It's 2linuxidc.com - Best Linux Practical Blog!");

}

運行以下命令編譯 rust 代碼。

$ rustc 2g.rs

上面的命令將在同一目錄中創建一個可執行的 Rust 程序。

$ ls-lh

total 3.9M

-rwxr-xr-x 1 linuxidc linuxidc 3.9MDec1411:092g

-rw-r--r--1 linuxidc linuxidc 86Dec1411:092g.rs

運行 Rust 可執行文件得到輸出。

$ ./2g

Hello,It's www.linuxidc.com - Best Linux Practical Blog!

好了!正常工作了。

將 Rust 更新到最新版本。

$ rustup update

info: syncing channel updates for'stable-x86_64-unknown-linux-gnu'

info: checking forself-updates

stable-x86_64-unknown-linux-gnu unchanged - rustc 1.31.0(abe02cefd 2018-12-04)

運行以下命令從系統中刪除 Rust 包。

$ rustup self uninstall

卸載 Rust 包后,刪除 Rust 項目目錄。

$ rm-fr ~/projects

總結

以上是生活随笔為你收集整理的rust安装教程linux,如何在 Linux 中安装 Rust 编程语言的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。