Fixed wasm build with string error and warning
This commit is contained in:
12
src/lib.rs
12
src/lib.rs
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
Reference in New Issue
Block a user