Crates.io | minimal-rust-wasm |
lib.rs | minimal-rust-wasm |
version | 0.2.0 |
source | src |
created_at | 2020-06-23 12:25:47.892047 |
updated_at | 2020-06-23 12:25:47.892047 |
description | An extremely minimal Rust + WASM example. |
homepage | |
repository | https://github.com/tuzz/minimal-rust-wasm |
max_upload_size | |
id | 257155 |
size | 15,920 |
An extremely minimal Rust + WASM example that works with GitHub pages. It demonstrates how to write to the DOM and how to call a JavaScript function from Rust. Hopefully this will serve as a helpful reference.
In one tab run:
$ ./bin/setup
$ ./bin/wasm_watch
In another tab run:
$ ./bin/server
If you're not on a Mac, you'll need to install binaryen
a different way.
Try changing "Hello, world!" to "Hello, foo!" in src/wasm_main.rs
. The
./bin/wasm_watch
script should automatically rebuild the project and
./bin/server
should reload the web page once that's done. Neat!
To deploy to GitHub pages run:
$ ./bin/deploy
It will compile the project then copy index.html
, target/index.wasm
and
target/index.js
to a tmp/
directory. This is then deployed to the gh-pages
branch for the current git repository.
Now that you have a working Rust/WASM workflow, refer to the book and the web_sys crate for more information.