WebAssembly (WASM) Runner
Write a Rust program, compile it with cargo build --release --target wasm32-unknown-unknown and upload the resulting *.wasm file here to call its functions with JavaScript.
See more details
- Create a new cargo crate with
cargo init --lib folder-name. cdinto thefolder-namefolder.- Replace
Cargo.tomlwith the below code. - Put your Rust code in
src/lib.rs. - Below is the example Rust program used as the default
.wasmfile below. - Your code can use the methods imported at the top of the above example.
Note: To use the print functions, refer to the above example. - Compile it using the command:
cargo build --release --target wasm32-unknown-unknown - Grab the file
target/wasm32-unknown-unknown/release/folder-name.wasmand upload it here. - If your file has a
mainmethod, it will be called automatically. - Use the JavaScript editor below to run JS and call your WASM functions.
Loading wasm-test.wasm…