MacOS に Rust をインストールする

Mac OS に Rust をインストールする

Rustの初体験:

なぜRustを選ぶのでしょうか?

Rust 言語には 3 つの主要なビジョンがあります。

  • 高いセキュリティ
  • ハイパフォーマンス
  • 高い同時実行性

Rust 言語は、信頼性が高く高速なソフトウェアを簡単な方法で開発することを目的としています。

Rust 言語は、システムレベル、さらにはマシンレベルのプログラムを作成するための最新の言語機能の使用をサポートしています。

インストールプロセス:

錆を取り付ける

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

中間のプロセスでは、インストール方法を選択できます: デフォルトのインストール方法、カスタム インストール、インストールのキャンセル。
ここに画像の説明を挿入

インストールの成功:

ここに画像の説明を挿入

貨物:

Rust のコンパイルおよびパッケージ管理ツール。

cargo --version: カーゴツールのバージョンを表示

上記のインストールが完了したら、次のようにします。

source ~/.bash_profile
cargo --version
cargo 1.62.1 (a748cf5a3 2022-06-08)

貨物は正常に取り付けられました。

プロジェクトを作成する

Hello World プロジェクトを作成して体験してください。

cargo new hello_workd
cd hello_workd/
tree .
.
├── Cargo.toml
└── src
    └── main.rs

1 directory, 2 files

「src/main.rs」を開きます。

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

コンパイル

cargo build
   Compiling hello_workd v0.1.0 (/Users/xxxxx/workstation/project/learn/rust/hello_workd)
    Finished dev [unoptimized + debuginfo] target(s) in 1.33s

実行して結果を表示する

./target/debug/hello_workd 
This is Hello, world!

または:

cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.04s
     Running `target/debug/hello_workd`
This is Hello, world!

参考:

https://www.rust-lang.org/

おすすめ

転載: blog.csdn.net/ziyunLLL/article/details/126088028