When compiling Rust for WASM, if the code panics, drop() isn't called. This repo is a repr for that behavior.
The code is in main.rs
Just cd to not-wasm
and run cargo run
. It print out "panicked at 'panic'", and then the line after should say "dropping".
The code is in lib.rs
.
cd to wasm
and run npm i; npm run dev
. Then go to http://localhost:8080 and once it all compiles, you should see one
alert box that says "no_panic", but not one that says "panic".