Lesson 42 of 50 · rust
WebAssembly with Rust
Duration: 25 minutes
Lesson 42 of 50 · rust
Duration: 25 minutes
wasm-pack.\n\nbash\ncargo new --lib hello_wasm\ncd hello_wasm\ncargo add wasm-bindgen\n\n\nrust\nuse wasm_bindgen::prelude::*;\n\n#[wasm_bindgen]\npub fn greet(name: &str) -> String {\n format!(\"Hello, {}!\", name)\n}\n\n\nBuild with:\n\nbash\nwasm-pack build --target web\n\n\nThen import the generated JS module in your web page.