技術共有

Rust開発環境の構築

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

Rust開発環境の構築

環境

rust: 1.79.0(2024-06-13)
  • 1

1. Rustup ダウンローダーのオンラインインストール

ウィンドウズ:

https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe

ユニックス:

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

2. Rust 独立インストールパッケージのオフラインインストール

ウィンドウズ:

https://static.rust-lang.org/dist/rust-1.79.0-x86_64-pc-windows-msvc.msi

リナックス:

https://static.rust-lang.org/dist/rust-1.79.0-x86_64-unknown-linux-gnu.tar.xz

マックOS:

https://static.rust-lang.org/dist/rust-1.79.0-x86_64-apple-darwin.pkg

3.Rustコマンドライン

  • 錆びたバージョンを見る
$ rustc -V
rustc 1.79.0
  • 1
  • 2
  • 新しいRustプロジェクトを作成する
cargo new hello_world
  • 1
  • Cargo は Rust プロジェクトをコンパイルします
$ cargo build
  • 1
  • Rustc は Rust プロジェクトをコンパイルします
$ rustc src/main.rs
  • 1
  • Rustプログラムを実行する
$ ./target/debug/hello_world
Hello, world!
  • 1
  • 2

4.IDE統合開発環境

4.1 VSコード

Visual Studio Code を使用した Rust

4.2 vs2022

[ユーザーマニュアル (rust-analyzer.github.io)

5. ミラーリングを使用して貨物を高速化する

次の内容を $CARGO_HOME/config に追加します

[source.crates-io]
replace-with = 'mirror'

[source.mirror]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
  • 1
  • 2
  • 3
  • 4
  • 5

注記:$CARGO_HOME: Windows システムのデフォルトは次のとおりです。%USERPROFILE%.cargo、Unix 系システムのデフォルトは次のとおりです。$HOME/.cargo


参照:

  1. その他のインストール方法 - Rust Forge (rust-lang.org)