-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Practical WebAssembly
By :
Cargo makes it easier to create, run, download, compile, test, and run your project. The cargo command provides a wrapper that calls the rustc compiler to start the compilation. In order to create WebAssembly modules using Rust's toolchain, we will be using a different target, wasm32-unknown-unknown.
The wasm32-unknown-unknown target adds zero runtime and toolchain footprint. wasm32 makes the compiler assume that only the wasm32 instruction set is present. The first unknown in unknown-unknown indicates the code can compile on any machine and the second indicates the code can run on any machine.
To see it in action, let's create a new project with Cargo:
$ cargo new --lib fib_wasm Created library `fib_wasm` package
A new project called fib_wasm is created. The new option creates a Rust project. The --lib flag informs Cargo to create a new library project rather than the default binary project.
The binary project will...