mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-13 04:51:23 +00:00
Fix codegen of consuming setters/getters (#2172)
Make sure they reset their internal pointer to null after we call Rust since it invalidates the Rust pointer after being called! Closes #2168
This commit is contained in:
@ -4,3 +4,21 @@ use wasm_bindgen::prelude::*;
|
||||
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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user