no_deref

no_deref 屬性可以用來說明不應為匯入的型別產生 Deref impl。 如果此屬性不存在,則會產生 Deref impl,其 Target 為該型別的第一個 extends 屬性,如果沒有 extends 屬性,則 Target = JsValue


# #![allow(unused_variables)]
#fn main() {
#[wasm_bindgen]
extern "C" {
    type Foo;

    #[wasm_bindgen(method)]
    fn baz(this: &Foo)

    #[wasm_bindgen(extends = Foo, no_deref)]
    type Bar;
}

fn do_stuff(bar: &Bar) {
    bar.baz() // Does not compile
}

#}