vride_api/lib.rs
1use wasm_bindgen::prelude::*;
2
3#[wasm_bindgen]
4extern {
5 pub fn alert(s: &str);
6}
7
8#[wasm_bindgen]
9pub fn greet(name: &str) {
10 alert(&format!("Hello, {}!", name));
11}
12
13#[no_mangle]
14pub extern fn print_hello_from_rust() {
15 println!("Hello from Rust");
16}
17
18#[cfg(test)]
19mod tests {
20 use super::{
21 print_hello_from_rust
22 };
23
24 #[test]
25 fn test_print() {
26 assert_eq!(print_hello_from_rust(), ());
27 }
28}