Sha256: b9972241b8d473d1a46ef3c2861065ca296cdc923883c404f19f1d859bf914a6

Contents?: true

Size: 949 Bytes

Versions: 30

Compression:

Stored size: 949 Bytes

Contents

# `skip`

When attached to a `pub` struct field this indicates that field will not be exposed to JavaScript,
and neither getter nor setter will be generated in ES6 class.

```rust
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub struct Foo {
    pub bar: u32,

    #[wasm_bindgen(skip)]
    pub baz: u32,
}

#[wasm_bindgen]
impl Foo {
    pub fn new() -> Self {
        Foo {
            bar: 1,
            baz: 2
        }
    }
}
```

Here the `bar` field will be both readable and writable from JS, but the
`baz` field will be `undefined` in JS.

```js
import('./pkg/').then(rust => {
    let foo = rust.Foo.new();
    
    // bar is accessible by getter
    console.log(foo.bar);
    // field marked with `skip` is undefined
    console.log(foo.baz);      

    // you can shadow it
    foo.baz = 45;       
    // so accessing by getter will return `45`
    // but it won't affect real value in rust memory
    console.log(foo.baz);
});
```

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
wasmtime-23.0.2 ./ext/cargo-vendor/wasm-bindgen-0.2.89/guide/src/reference/attributes/on-rust-exports/skip.md
wasmtime-22.0.0 ./ext/cargo-vendor/wasm-bindgen-0.2.89/guide/src/reference/attributes/on-rust-exports/skip.md
wasmtime-21.0.1 ./ext/cargo-vendor/wasm-bindgen-0.2.89/guide/src/reference/attributes/on-rust-exports/skip.md
wasmtime-20.0.2 ./ext/cargo-vendor/wasm-bindgen-0.2.89/guide/src/reference/attributes/on-rust-exports/skip.md
wasmtime-20.0.0 ./ext/cargo-vendor/wasm-bindgen-0.2.89/guide/src/reference/attributes/on-rust-exports/skip.md
wasmtime-18.0.3 ./ext/cargo-vendor/wasm-bindgen-0.2.89/guide/src/reference/attributes/on-rust-exports/skip.md
wasmtime-17.0.1 ./ext/cargo-vendor/wasm-bindgen-0.2.89/guide/src/reference/attributes/on-rust-exports/skip.md
wasmtime-17.0.0 ./ext/cargo-vendor/wasm-bindgen-0.2.89/guide/src/reference/attributes/on-rust-exports/skip.md
wasmtime-16.0.0 ./ext/cargo-vendor/wasm-bindgen-0.2.89/guide/src/reference/attributes/on-rust-exports/skip.md
wasmtime-15.0.1 ./ext/cargo-vendor/wasm-bindgen-0.2.89/guide/src/reference/attributes/on-rust-exports/skip.md
wasmtime-15.0.0 ./ext/cargo-vendor/wasm-bindgen-0.2.89/guide/src/reference/attributes/on-rust-exports/skip.md
wasmtime-14.0.4 ./ext/cargo-vendor/wasm-bindgen-0.2.87/guide/src/reference/attributes/on-rust-exports/skip.md
wasmtime-14.0.3 ./ext/cargo-vendor/wasm-bindgen-0.2.87/guide/src/reference/attributes/on-rust-exports/skip.md
wasmtime-14.0.1 ./ext/cargo-vendor/wasm-bindgen-0.2.87/guide/src/reference/attributes/on-rust-exports/skip.md
wasmtime-14.0.0 ./ext/cargo-vendor/wasm-bindgen-0.2.87/guide/src/reference/attributes/on-rust-exports/skip.md
wasmtime-13.0.0 ./ext/cargo-vendor/wasm-bindgen-0.2.87/guide/src/reference/attributes/on-rust-exports/skip.md
wasmtime-12.0.1 ./ext/cargo-vendor/wasm-bindgen-0.2.87/guide/src/reference/attributes/on-rust-exports/skip.md
wasmtime-12.0.0 ./ext/cargo-vendor/wasm-bindgen-0.2.87/guide/src/reference/attributes/on-rust-exports/skip.md
wasmtime-11.0.0 ./ext/cargo-vendor/wasm-bindgen-0.2.87/guide/src/reference/attributes/on-rust-exports/skip.md
wasmtime-10.0.1 ./ext/cargo-vendor/wasm-bindgen-0.2.87/guide/src/reference/attributes/on-rust-exports/skip.md