5 stable releases
|1.0.4||Nov 21, 2021|
|1.0.0||Nov 19, 2021|
#649 in WebAssembly
25 downloads per month
Try It Out Locally
Clone this repository onto your machine.
cargo install wasm-gc. This is used by
build-demo.shto reduce the size of the compiled wasm binary by removing unneccesary/unused cruft. Even though the
wasm-gcproject itself says you shouldn't use it in most cases, it still seems to get the wasm file the smallest. I tried using the
--gc-sectionsflag in the compiler options and
wasm-gcstill got it smaller. I am not making use of
wasm-packin this project, which both attempt to remove cruft when compiling, so I utilized
wasm-gcto do it manually.
./build-demo.shin the repository root. This creates the
monotone_crescendo.wasmbinary and an
index.htmlfile in a directory named
demoin the repository root.
demo/and run an http server. Using python's
SimpleHTTPServer, for example:
cd demo/ python -m SimpleHTTPServer
The demo will then be available at
Detailed documnetation generated via rustdoc can be found alongside the demo.
Huge credit to Dr. Richard Apodaca and his blog, depth-first.com, without which I'm not sure I would have been able to make sense of how to read and write from WebAssembly's linear memory without having to dive straight into something like
These two blog posts from Dr. Apodaca were most helpful:
- Compiling Rust to WebAssembly: A Simple Example
- Rust and WebAssembly from Scratch: Hello World with Strings
Further credit goes to Radu Matei and his blog post, which helped me build upon the concepts I learned from Dr. Apodaca's posts.
The prefix sum solution is the official solution on LeetCode, I only translated it into Rust.
The cumulative solution was posted to LeetCode by tarunbisht, and was translated into Rust by me.