Wasm_bindgen :: arguments cannot be `self`

pub trait Rust_Handle_Trait {
    fn resize(&self, width: u32, height: u32);

pub struct Rust_Handle_Js {
    handle: Rc<dyn Rust_Handle_Trait>,}

impl Rust_Handle_Js {
    pub fn new(t: Rc<dyn Rust_Handle_Trait>) -> Rust_Handle_Js {
        Rust_Handle_Js { handle: r}}}

impl Rust_Handle_Js {
    pub fn resize(&self, width: u32, height: u32) {
        self.handle.resize(width, height);}}

wasm_bindgen seems to dislike the &self in the pub fn resize.


  1. I don't understand what the problem is. The struct itself is #[wasm_bindgen]

  2. How do I get around this issue?

I'm curious why you have two identical bindgen attributes, one for resize and one for the outer impl block. I haven't tested the code but that looks wrong to me. The inner bindgen shouldn't be there.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.