mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-05-22 18:31:18 +00:00
27 lines
542 B
Rust
27 lines
542 B
Rust
|
#![feature(proc_macro)]
|
||
|
|
||
|
extern crate wasm_bindgen;
|
||
|
|
||
|
use wasm_bindgen::prelude::*;
|
||
|
|
||
|
#[wasm_bindgen]
|
||
|
extern {
|
||
|
#[wasm_bindgen(namespace = Math)]
|
||
|
fn log2(a: f64) -> f64;
|
||
|
#[wasm_bindgen(namespace = Math)]
|
||
|
fn sin(a: f64) -> f64;
|
||
|
|
||
|
#[wasm_bindgen(namespace = console)]
|
||
|
fn log(a: &str);
|
||
|
}
|
||
|
|
||
|
macro_rules! println {
|
||
|
($($t:tt)*) => (console::log(&format_args!($($t)*).to_string()))
|
||
|
}
|
||
|
|
||
|
#[wasm_bindgen]
|
||
|
pub fn run() {
|
||
|
println!("Math.log2(10.0) = {}", Math::log2(10.0));
|
||
|
println!("Math.sin(1.2) = {}", Math::sin(1.2));
|
||
|
}
|