mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-15 22:11:23 +00:00
Add an example of console.log
Also clean up some other exampels
This commit is contained in:
18
examples/console_log/src/lib.rs
Normal file
18
examples/console_log/src/lib.rs
Normal file
@ -0,0 +1,18 @@
|
||||
#![feature(proc_macro)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen]
|
||||
extern {
|
||||
type console;
|
||||
|
||||
#[wasm_bindgen(static = console)]
|
||||
fn log(s: &str);
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn run() {
|
||||
console::log("Hello from Rust!");
|
||||
}
|
Reference in New Issue
Block a user