File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed
examples/guide-supported-types-examples/src
guide/src/reference/types Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -2,9 +2,16 @@ use wasm_bindgen::prelude::*;
2
2
3
3
#[ wasm_bindgen]
4
4
pub struct ExportedNamedStruct {
5
+ // pub value: String, // This won't work. See working example below.
5
6
pub inner : u32 ,
6
7
}
7
8
9
+ #[ wasm_bindgen( getter_with_clone) ]
10
+ pub struct ExportedNamedStructNonCopy {
11
+ pub non_copy_value : String ,
12
+ pub copy_value : u32 ,
13
+ }
14
+
8
15
#[ wasm_bindgen]
9
16
pub fn named_struct_by_value ( x : ExportedNamedStruct ) { }
10
17
Original file line number Diff line number Diff line change 4
4
| :---:| :---:| :---:| :---:| :---:| :---:| :---:|
5
5
| Yes | Yes | Yes | Yes | Yes | Yes | Instances of a ` wasm-bindgen ` -generated JavaScript ` class Whatever { ... } ` |
6
6
7
+ > ** Note** : Public fields implementing Copy have automatically generated getters/setters.
8
+ > To generate getters/setters for non-Copy public fields, use #[ wasm_bindgen(getter_with_clone)] for the struct
9
+ > or [ implement getters/setters manually] ( https://rustwasm.github.io/wasm-bindgen/reference/attributes/on-rust-exports/getter-and-setter.html ) .
7
10
## Example Rust Usage
8
11
9
12
``` rust
You can’t perform that action at this time.
0 commit comments