Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
pub fn add_one(x: i32) -> i32 {
x + 1
// needed for no_std
#[lang = "panic_fmt"]
pub extern fn rust_begin_panic(_msg: core::fmt::Arguments,
_file: &'static str,
_line: u32,
_column: u32) -> ! {
loop {}
$ rustup update nightly
$ rustup target add wasm32-unknown-unknown --toolchain nightly
$ rustc +nightly --target wasm32-unknown-unknown -O .\ --crate-type=cdylib
$ cargo install --git
$ wasm-gc .\add.wasm small-add.wasm
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<title>wasm wasm wasm</title>
fetch('small-add.wasm').then(response =>
).then(bytes =>
WebAssembly.instantiate(bytes, {})
).then(results => {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.