Fixed wasm build with string error and warning

This commit is contained in:
2020-08-20 16:17:44 +07:00
parent cc6b0c38db
commit e7b88b96e1
5 changed files with 24 additions and 20 deletions

View File

@@ -1,4 +1,5 @@
use wasm_bindgen::prelude::*;
use math;
extern crate web_sys;
@@ -21,18 +22,13 @@ extern {
}
#[wasm_bindgen]
extern {
fn sum(a: i32, b: i32) -> i32;
}
#[wasm_bindgen]
pub fn greet() {
alert("Hey, CUBETIQ Solution!");
pub fn greet() -> String {
"Hey, CUBETIQ Solution!".into()
}
#[wasm_bindgen]
pub fn just_sum() -> i32 {
let sum = sum(100, 50);
let sum = math::sum(100, 50);
log(&format!("Just Sum {} + {} = {}", 100, 50, sum));
return sum;
}

View File

@@ -2,5 +2,10 @@ use math;
fn main() {
let sum = math::sum(1, 2);
println!("Sum number {}", sum)
println!("Sum number {}", sum);
println!("Greetings, {}", welcome());
}
fn welcome() -> String {
return String::from("Hello, Sambo")
}