This is my first try with WebAssembly through Rust.
index.html
returns the factorial of 5.
Simply open the index.html file to see the application running.
In order to obtain the .wasm files I ran a few commands in the following order:
rustc +nightly --target wasm32-unknown-unknown -O factorial.rs --crate-type=cdylib
Which generates a WebAssembly (.wasm) file of the same name as the original Rust file.
wasm-gc factorial.rs small-factorial.wasm
factorial.rs
has been created in the prior step. Now wasm-gc helps us
minimize the code, for instance, by removing unused code. The resulting file
will be named as stated in the second argument, here small-factorial.wasm
.
- Native Wasm Target - News
- Minimal Rust & WebAssembly example
- Code (associated with the secondly enumerated item).