$ rustc -V
rustc 1.59.0 (9d1b2106e 2022-02-23)
# Rustのビルドツールおよびパッケージ管理ツール
$ cargo --version
cargo 1.59.0 (49d8809dc 2022-02-10)
# 管理ツール
$ rustup -V
rustup 1.24.3 (ce5817a94 2021-05-31)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.59.0 (9d1b2106e 2022-02-23)`
# 有効なツールチェインの確認
$ rustup show
Default host: x86_64-unknown-linux-gnu
rustup home: /home/ariki/.rustup
installed targets for active toolchain
--------------------------------------
wasm32-unknown-unknown
x86_64-unknown-linux-gnu
active toolchain
----------------
stable-x86_64-unknown-linux-gnu (default)
rustc 1.59.0 (9d1b2106e 2022-02-23)
wasm-packのインストール
cargo install wasm-pack
WebAssembly パッケージのビルド
Rust で新しいパッケージを作ります。任意の階層で下記のコマンドを実行します。
$ cargo new --lib hello-wasm
Created library `hello-wasm` project