0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Rust入門

Posted at

1 環境構築

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


   default host triple: aarch64-apple-darwin
     default toolchain: stable (default)
               profile: default
  modify PATH variable: yes

1) Proceed with standard installation (default - just press enter)
2) Customize installation
3) Cancel installation
>

1を押してインストール

Rust is installed now. Great!

To get started you may need to restart your current shell.
This would reload your PATH environment variable to include
Cargo's bin directory ($HOME/.cargo/bin).

To configure your current shell, you need to source
the corresponding env file under $HOME/.cargo.

This is usually done by running one of the following (note the leading DOT):
. "$HOME/.cargo/env"            # For sh/bash/zsh/ash/dash/pdksh
source "$HOME/.cargo/env.fish"  # For fish

メッセージに従って以下を実行
下のコマンドはfish shell用らしい。

. "$HOME/.cargo/env"

以下が動けば成功

rustup --version
rustup 1.27.1 (54dd3d00f 2024-04-24)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.81.0 (eeb90cda1 2024-09-04)`

rustcのバージョンとは違うと教えてくれる

rustc --version
rustc 1.81.0 (eeb90cda1 2024-09-04)

rustcやらrustupやらの違いは以下のようになっているらしいです(ふわふわ)

  • rustup:管理ツールのようです
  • rustc:コンパイラ
  • cargo:ビルドツール兼パッケージマネージャ(rustupと役割が被ってる印象、インストール時の挙動に違いがあるようです)
    • rustup component add:バイナリDL、
    • cargo install:ソースDL後ローカルでビルドされる違いがある

Rustではクロスコンパイルというのができるらしい

RustをビルドしてWebAssenmblyを使用するのにビルドターゲットを追加する

# ビルドターゲットの一覧が表示される
rustup target list
# 以下2つ追加する
rustup target add wasm32-unknown-unknown
rustup target add wasm32-wasip1  
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?