# hello-rust **Repository Path**: mirrors_dsyer/hello-rust ## Basic Information - **Project Name**: hello-rust - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-04-13 - **Last Updated**: 2026-03-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README Broadly following this useful [tutorial](https://rustwasm.github.io/book/game-of-life/setup.html), which details all the prerequiistes. Attempt to build it (expect some warnings as well): ``` $ wasm-pack build --target web ... warning: function is never used: `set_panic_hook` --> src/utils.rs:1:8 | 1 | pub fn set_panic_hook() { | ^^^^^^^^^^^^^^ | = note: `#[warn(dead_code)]` on by default warning: `hello-rust` (lib) generated 1 warning Finished release [optimized] target(s) in 12.57s [INFO]: Installing wasm-bindgen... [INFO]: Optional fields missing from Cargo.toml: 'description', 'repository', and 'license'. These are not necessary, but recommended [INFO]: :-) Done in 16.03s [INFO]: :-) Your wasm pkg is ready to publish at /home/dsyer/dev/scratch/hello-rust/pkg. [WARN]: :-) [60] SSL peer certificate or SSH remote key was not OK (SSL certificate problem: unable to get local issuer certificate) ``` > NOTE: to use the `nix-shell` with the `shell.nix` from this repo you will need to switch off wasm optimization in `Cargo.toml` (per the instructions from the build error): > > [package.metadata.wasm-pack.profile.release] > wasm-opt = false The JavaScript is so trivial we could embed it directly in the `index.html`: ```html

Hello

``` For Node.js we need a wrapper (`bundle.js`) that defines some shims for the browser: ```javascript globalThis.alert = (...args) => { console.log(...args); } import init, { greet } from "./hello_rust.js"; const bytes = fs.readFileSync(path.dirname(import.meta.url).replace('file://', '') + '/hello_rust_bg.wasm'); let wasm = await init(bytes); export { wasm, greet }; export default greet; ``` Run it after building the Spring Boot project so that the static resources are copied over to `./target`: ```javascript $ node Welcome to Node.js v16.14.2. Type ".help" for more information. > var {greet} = await import('./target/classes/static/bundle.js') > greet() Hello, hello-rust! ```