mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-04-11 06:36:05 +00:00
Make sure they reset their internal pointer to null after we call Rust since it invalidates the Rust pointer after being called! Closes #2168
25 lines
391 B
Rust
25 lines
391 B
Rust
use wasm_bindgen::prelude::*;
|
|
|
|
#[wasm_bindgen]
|
|
pub fn add(a: u32, b: u32) -> u32 {
|
|
a + b
|
|
}
|
|
|
|
#[wasm_bindgen]
|
|
#[derive(Copy, Clone)]
|
|
pub struct Answer(u32);
|
|
|
|
#[wasm_bindgen]
|
|
impl Answer {
|
|
pub fn new() -> Answer {
|
|
Answer(41)
|
|
}
|
|
#[wasm_bindgen(getter)]
|
|
pub fn the_answer(self) -> u32 {
|
|
self.0 + 1
|
|
}
|
|
pub fn foo(self) -> u32 {
|
|
self.0 + 1
|
|
}
|
|
}
|