This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate wasm_bindgen; | |
extern crate web_sys; | |
use wasm_bindgen::prelude::*; | |
#[wasm_bindgen] | |
pub fn run() -> Result<(), JsValue> { | |
let window = web_sys::window().expect("no global `window` exists"); | |
let document = window.document().expect("should have a document on window"); | |
let body = document.body().expect("document should have a body"); | |
let val = document.create_element("p")?; | |
val.set_inner_html("Hello from Rust!"); | |
AsRef::<web_sys::Node>::as_ref(&body).append_child(val.as_ref())?; | |
Ok(()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment