WebAssembly support

Minimum Rust version: 1.14 for emscripten

Minimum Rust version: nightly for wasm32-unknown-unknown

Rust has gained support for WebAssembly, meaningthat you can run Rust code in your browser, client-side.

In Rust 1.14, we gained support throughemscripten. With itinstalled, you can write Rust code and have it produceasm.js (the precusor to wasm) and/or WebAssembly.

Here's an example of using this support:

  1. $ rustup target add wasm32-unknown-emscripten
  2. $ echo 'fn main() { println!("Hello, Emscripten!"); }' > hello.rs
  3. $ rustc --target=wasm32-unknown-emscripten hello.rs
  4. $ node hello.js

However, in the meantime, Rust has also grown its own support, independentfrom Emscripten. This is known as "the unknown target", because instead ofwasm32-unknown-emscripten, it's wasm32-unknown-unknown. This will bethe preferred target to use once it's ready, but for now, it's reallyonly well-supported in nightly.