From c20d2f3085059777bf82bf6a37cc1db08be848eb Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sat, 25 Feb 2023 11:14:25 -0500 Subject: [PATCH] Add this_algorithm-wasm --- this_algorithm-wasm/Cargo.toml | 13 +++++++++++++ this_algorithm-wasm/src/lib.rs | 11 +++++++++++ 2 files changed, 24 insertions(+) create mode 100644 this_algorithm-wasm/Cargo.toml create mode 100644 this_algorithm-wasm/src/lib.rs diff --git a/this_algorithm-wasm/Cargo.toml b/this_algorithm-wasm/Cargo.toml new file mode 100644 index 0000000..a0624a0 --- /dev/null +++ b/this_algorithm-wasm/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "this_algorithm-wasm" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +crate-type = ["cdylib"] + +[dependencies] +wasm-bindgen = "0.2" +# this_algorithm = {path=".."} diff --git a/this_algorithm-wasm/src/lib.rs b/this_algorithm-wasm/src/lib.rs new file mode 100644 index 0000000..d49cf4d --- /dev/null +++ b/this_algorithm-wasm/src/lib.rs @@ -0,0 +1,11 @@ +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +extern "C" { + pub fn alert(s: &str); +} + +#[wasm_bindgen] +pub fn greet(name: &str) { + alert(&format!("Hello, {}!", name)); +}