Rust で WASI 対応の WebAssembly を作って、スタンドアロン実行や Web ブラウザ上での実行を試してみました。 WASI︵WebAssembly SystemInterface︶ は WebAssembly のコードを様々なプラットフォームで実行するためのインターフェースで、これに対応した WebAssembly であれば Web ブラウザ外で実行できます。 Rust で WASI 対応の WebAssembly を作るのは簡単で、ビルドターゲットに wasm32-wasi を追加しておいて、rustcや cargo build によるビルド時に --target wasm32-wasi を指定するだけでした。 wasm32-wasi の追加 > rustup target add wasm32-wasi 標準出力へ文字列を出力するだけの下記サンプルコードを --
![Rust で WASI 対応の WebAssembly を作成して実行 - なんとなくな Developer のメモ](https://cdn-ak-scissors.b.st-hatena.com/image/square/8b7be6b79f67f470b70ab4feefc2f457f79be32e/height=288;version=1;width=512/https%3A%2F%2Fcdn-ak.f.st-hatena.com%2Fimages%2Ffotolife%2Ff%2Ffits%2F20200429%2F20200429200738.png)