Our great sponsors
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
-
cargo-generate
Discontinued cargo, make me a project [Moved to: https://github.com/cargo-generate/cargo-generate] (by ashleygwilliams)
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
-
console_error_panic_hook
A panic hook for wasm32-unknown-unknown that logs panics with console.error
wasm-bindgen for communicating between WebAssembly and JavaScript.
The book avoids both pitfalls as it follows the first pattern but provides optional problems at the end of each chapter. To avoid blocking the learner, each problem provides a general hint to lead learners to the solution. If you cannot (or do not want to) solve a specific problem, you can continue onto the next chapter anyway. Note that in the associated Git repository, each commit references either a standard copy-paste step or a problem to solve.
The first tutorial step focuses on the setup. It's short and is the most "copy-pastey" of all. The reason for that is that it leverages cargo-generate, a Cargo plugin that allows creating a new project by using an existing Git repository as a template. In our case, the template is a Rust project ready to compile to Wasm. The project's structure is:
The first tutorial step focuses on the setup. It's short and is the most "copy-pastey" of all. The reason for that is that it leverages cargo-generate, a Cargo plugin that allows creating a new project by using an existing Git repository as a template. In our case, the template is a Rust project ready to compile to Wasm. The project's structure is:
As for the previous step, a command allows copying code from GitHub. Here, the command is npm, and the template is create-wasm-app. Let's run the command:
cargo generate --git https://github.com/rustwasm/wasm-pack-template.git --name my-project cd my-project
Learn more about cargo generate here.
console_error_panic_hook for logging panic messages to the developer console.
wee_alloc, an allocator optimized for small code size.