Open mstange opened 5 years ago
Thanks for the sharp eye! Your intuition here is spot on the example is definitely more instructive!
FWIW movement does not copy values, and it causes the JS value to throw an error if it's ever reused. Would be good to document this though explicitly!
On the page Exported
struct Whatever
Rust Types, there is no information about what happens if you pass such a type from JS to rust by value. Does the value get copied? Does the value get "moved"? Is the JS object still usable after you call the rust function?And then the JS code in example causes even more confusion:
First, the example passes
namedStruct
into a rust function by value, and then passes the same object into two other rust functions by reference. When you actually run this code, it will throw errors.I recommend the following paragraph be added at the top:
And the example should be changed to: